Logo Search packages:      
Sourcecode: mysql-connector-java version File versions  Download package

void com::mysql::jdbc::ServerPreparedStatement::storeBinding ( Buffer  packet,
BindValue  bindValue,
MysqlIO  mysql 
) throws SQLException [inline, private]

Method storeBinding.

Parameters:
packet 
bindValue 
mysql DOCUMENT ME!
Exceptions:
SQLException DOCUMENT ME!

Definition at line 2212 of file ServerPreparedStatement.java.

References com::mysql::jdbc::StatementImpl::charConverter, com::mysql::jdbc::StatementImpl::charEncoding, com::mysql::jdbc::StatementImpl::connection, getBytes(), com::mysql::jdbc::ConnectionPropertiesImpl::getEncoding(), com::mysql::jdbc::ConnectionImpl::getServerCharacterEncoding(), com::mysql::jdbc::PreparedStatement::isLoadDataQuery, and com::mysql::jdbc::ConnectionImpl::parserKnowsUnicode.

Referenced by getBytes(), and serverExecute().

                                      {
            try {
                  Object value = bindValue.value;

                  //
                  // Handle primitives first
                  //
                  switch (bindValue.bufferType) {

                  case MysqlDefs.FIELD_TYPE_TINY:
                        packet.writeByte(bindValue.byteBinding);
                        return;
                  case MysqlDefs.FIELD_TYPE_SHORT:
                        packet.ensureCapacity(2);
                        packet.writeInt(bindValue.shortBinding);
                        return;
                  case MysqlDefs.FIELD_TYPE_LONG:
                        packet.ensureCapacity(4);
                        packet.writeLong(bindValue.intBinding);
                        return;
                  case MysqlDefs.FIELD_TYPE_LONGLONG:
                        packet.ensureCapacity(8);
                        packet.writeLongLong(bindValue.longBinding);
                        return;
                  case MysqlDefs.FIELD_TYPE_FLOAT:
                        packet.ensureCapacity(4);
                        packet.writeFloat(bindValue.floatBinding);
                        return;
                  case MysqlDefs.FIELD_TYPE_DOUBLE:
                        packet.ensureCapacity(8);
                        packet.writeDouble(bindValue.doubleBinding);
                        return;
                  case MysqlDefs.FIELD_TYPE_TIME:
                        storeTime(packet, (Time) value);
                        return;
                  case MysqlDefs.FIELD_TYPE_DATE:
                  case MysqlDefs.FIELD_TYPE_DATETIME:
                  case MysqlDefs.FIELD_TYPE_TIMESTAMP:
                        storeDateTime(packet, (java.util.Date) value, mysql);
                        return;
                  case MysqlDefs.FIELD_TYPE_VAR_STRING:
                  case MysqlDefs.FIELD_TYPE_STRING:
                  case MysqlDefs.FIELD_TYPE_VARCHAR:
                  case MysqlDefs.FIELD_TYPE_DECIMAL:
                  case MysqlDefs.FIELD_TYPE_NEW_DECIMAL:
                        if (value instanceof byte[]) {
                              packet.writeLenBytes((byte[]) value);
                        } else if (!this.isLoadDataQuery) {
                              packet.writeLenString((String) value, this.charEncoding,
                                          this.connection.getServerCharacterEncoding(),
                                          this.charConverter, this.connection
                                                      .parserKnowsUnicode(),
                                                      this.connection);
                        } else {
                              packet.writeLenBytes(((String) value).getBytes());
                        }

                        return;
                  }

                  
            } catch (UnsupportedEncodingException uEE) {
                  throw SQLError.createSQLException(Messages
                              .getString("ServerPreparedStatement.22") //$NON-NLS-1$
                              + this.connection.getEncoding() + "'", //$NON-NLS-1$
                              SQLError.SQL_STATE_GENERAL_ERROR);
            }
      }


Generated by  Doxygen 1.6.0   Back to index