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

String com::mysql::jdbc::ResultSet::extractStringFromNativeColumn ( int  columnIndex,
int  mysqlType 
) throws SQLException [inline, private]

Parameters:
columnIndex 
stringVal 
mysqlType 
Returns:
Exceptions:
SQLException 

Definition at line 4157 of file ResultSet.java.

References com::mysql::jdbc::SingleByteCharsetConverter::toString().

                                                                                                       {
            if (this.thisRow[columnIndex - 1] instanceof String) {
                return (String) this.thisRow[columnIndex - 1];
            }

            String stringVal = null;
            
            if ((this.connection != null) && this.connection.getUseUnicode()) {
                try {
                    String encoding = this.fields[columnIndex - 1].getCharacterSet();

                    if (encoding == null) {
                        stringVal = new String((byte[]) this.thisRow[columnIndex -
                                1]);
                    } else {
                        SingleByteCharsetConverter converter = this.connection.getCharsetConverter(encoding);

                        if (converter != null) {
                            stringVal = converter.toString((byte[]) this.thisRow[columnIndex -
                                    1]);
                        } else {
                            stringVal = new String((byte[]) this.thisRow[columnIndex -
                                    1], encoding);
                        }
                    }
                } catch (java.io.UnsupportedEncodingException E) {
                    throw new SQLException(Messages.getString(
                            "ResultSet.Unsupported_character_encoding____138") //$NON-NLS-1$
                         + this.connection.getEncoding() + "'.", "0S100");
                }
            } else {
                stringVal = StringUtils.toAsciiString((byte[]) this.thisRow[columnIndex -
                        1]);
            }

            // Cache this conversion if the type is a MySQL string type
            if ((mysqlType == MysqlDefs.FIELD_TYPE_STRING) ||
                    (mysqlType == MysqlDefs.FIELD_TYPE_VAR_STRING) ||
                        (mysqlType == MysqlDefs.FIELD_TYPE_VARCHAR)) {
                this.thisRow[columnIndex - 1] = stringVal;
            }

            return stringVal;
      }


Generated by  Doxygen 1.6.0   Back to index