Example usage for java.sql Types TINYINT

List of usage examples for java.sql Types TINYINT

Introduction

In this page you can find the example usage for java.sql Types TINYINT.

Prototype

int TINYINT

To view the source code for java.sql Types TINYINT.

Click Source Link

Document

The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type TINYINT.

Usage

From source file:com.squid.core.domain.operators.ExtendedType.java

public static int FromTypeName(String SQLName) {
    if (SQLName.equals("ARRAY")) {
        return Types.ARRAY;
    }/*from   w ww  .  j a v  a  2s  . com*/
    if (SQLName.equals("INTEGER")) {
        return Types.INTEGER;
    }
    if (SQLName.equals("BINARY")) {
        return Types.BINARY;
    }
    if (SQLName.equals("BIT")) {
        return Types.BIT;
    }
    if (SQLName.equals("BLOB")) {
        return Types.BLOB;
    }
    if (SQLName.equals("BOOLEAN")) {
        return Types.BOOLEAN;
    }
    if (SQLName.equals("CHAR")) {
        return Types.CHAR;
    }
    if (SQLName.equals("CLOB")) {
        return Types.CLOB;
    }
    if (SQLName.equals("DATALINK")) {
        return Types.DATALINK;
    }
    if (SQLName.equals("DATE")) {
        return Types.DATE;
    }
    if (SQLName.equals("DECIMAL")) {
        return Types.DECIMAL;
    }
    if (SQLName.equals("DOUBLE")) {
        return Types.DOUBLE;
    }
    if (SQLName.equals("FLOAT")) {
        return Types.FLOAT;
    }
    if (SQLName.equals("JAVA_OBJECT")) {
        return Types.JAVA_OBJECT;
    }
    if (SQLName.equals("LONGNVARCHAR")) {
        return Types.LONGNVARCHAR;
    }
    if (SQLName.equals("LONGVARBINARY")) {
        return Types.LONGVARBINARY;
    }
    if (SQLName.equals("NCHAR")) {
        return Types.NCHAR;
    }
    if (SQLName.equals("NCLOB")) {
        return Types.NCLOB;
    }
    if (SQLName.equals("UNDEFINED")) {
        return Types.OTHER;
    }
    if (SQLName.equals("NUMERIC")) {
        return Types.NUMERIC;
    }
    if (SQLName.equals("NVARCHAR")) {
        return Types.NVARCHAR;
    }
    if (SQLName.equals("REAL")) {
        return Types.REAL;
    }
    if (SQLName.equals("REF")) {
        return Types.REF;
    }
    if (SQLName.equals("ROWID")) {
        return Types.ROWID;
    }
    if (SQLName.equals("SMALLINT")) {
        return Types.SMALLINT;
    }
    if (SQLName.equals("SQLXML")) {
        return Types.SQLXML;
    }
    if (SQLName.equals("STRUCT")) {
        return Types.STRUCT;
    }
    if (SQLName.equals("TIME")) {
        return Types.TIME;
    }
    if (SQLName.equals("TIMESTAMP")) {
        return Types.TIMESTAMP;
    }
    if (SQLName.equals("TINYINT")) {
        return Types.TINYINT;
    }
    if (SQLName.equals("VARCHAR")) {
        return Types.VARCHAR;
    }
    if (SQLName.equals("VARBINARY")) {
        return Types.VARBINARY;
    }
    return Types.OTHER;
}

From source file:com.mapd.utility.SQLImporter.java

private String getColType(int cType, int precision, int scale) {
    if (precision > 19) {
        precision = 19;/* w ww.  j av  a  2  s .  c o  m*/
    }
    if (scale > 19) {
        scale = 18;
    }
    switch (cType) {
    case java.sql.Types.TINYINT:
    case java.sql.Types.SMALLINT:
        return ("SMALLINT");
    case java.sql.Types.INTEGER:
        return ("INTEGER");
    case java.sql.Types.BIGINT:
        return ("BIGINT");
    case java.sql.Types.FLOAT:
        return ("FLOAT");
    case java.sql.Types.DECIMAL:
        return ("DECIMAL(" + precision + "," + scale + ")");
    case java.sql.Types.DOUBLE:
        return ("DOUBLE");
    case java.sql.Types.REAL:
        return ("REAL");
    case java.sql.Types.NUMERIC:
        return ("NUMERIC(" + precision + "," + scale + ")");
    case java.sql.Types.TIME:
        return ("TIME");
    case java.sql.Types.TIMESTAMP:
        return ("TIMESTAMP");
    case java.sql.Types.DATE:
        return ("DATE");
    case java.sql.Types.BOOLEAN:
    case java.sql.Types.BIT: // deal with postgress treating boolean as bit... this will bite me
        return ("BOOLEAN");
    case java.sql.Types.NVARCHAR:
    case java.sql.Types.VARCHAR:
    case java.sql.Types.NCHAR:
    case java.sql.Types.CHAR:
    case java.sql.Types.LONGVARCHAR:
    case java.sql.Types.LONGNVARCHAR:
        return ("TEXT ENCODING DICT");
    default:
        throw new AssertionError("Column type " + cType + " not Supported");
    }
}

From source file:jongo.jdbc.JDBCExecutor.java

/**
 * Utility method which registers in a CallableStatement object the different {@link jongo.jdbc.StoredProcedureParam}
 * instances in the given list. Returns a List of {@link jongo.jdbc.StoredProcedureParam} with all the OUT parameters
 * registered in the CallableStatement//from   ww  w .j av  a 2  s. c o  m
 * @param cs the CallableStatement object where the parameters are registered.
 * @param params a list of {@link jongo.jdbc.StoredProcedureParam}
 * @return a list of OUT {@link jongo.jdbc.StoredProcedureParam} 
 * @throws SQLException if we fail to register any of the parameters in the CallableStatement
 */
private static List<StoredProcedureParam> addParameters(final CallableStatement cs,
        final List<StoredProcedureParam> params) throws SQLException {
    List<StoredProcedureParam> outParams = new ArrayList<StoredProcedureParam>();
    int i = 1;
    for (StoredProcedureParam p : params) {
        final Integer sqlType = p.getType();
        if (p.isOutParameter()) {
            l.debug("Adding OUT parameter " + p.toString());
            cs.registerOutParameter(i++, sqlType);
            outParams.add(p);
        } else {
            l.debug("Adding IN parameter " + p.toString());
            switch (sqlType) {
            case Types.BIGINT:
            case Types.INTEGER:
            case Types.TINYINT:
                //                    case Types.NUMERIC:
                cs.setInt(i++, Integer.valueOf(p.getValue()));
                break;
            case Types.DATE:
                cs.setDate(i++, (Date) JongoUtils.parseValue(p.getValue()));
                break;
            case Types.TIME:
                cs.setTime(i++, (Time) JongoUtils.parseValue(p.getValue()));
                break;
            case Types.TIMESTAMP:
                cs.setTimestamp(i++, (Timestamp) JongoUtils.parseValue(p.getValue()));
                break;
            case Types.DECIMAL:
                cs.setBigDecimal(i++, (BigDecimal) JongoUtils.parseValue(p.getValue()));
                break;
            case Types.DOUBLE:
                cs.setDouble(i++, Double.valueOf(p.getValue()));
                break;
            case Types.FLOAT:
                cs.setLong(i++, Long.valueOf(p.getValue()));
                break;
            default:
                cs.setString(i++, p.getValue());
                break;
            }
        }
    }
    return outParams;
}

From source file:org.waarp.common.database.data.AbstractDbData.java

/**
 * Get one value into DbValue from ResultSet
 * //from  w w  w .  j  a v  a2 s  . co m
 * @param rs
 * @param value
 * @throws WaarpDatabaseSqlException
 */
static public void getTrueValue(ResultSet rs, DbValue value) throws WaarpDatabaseSqlException {
    try {
        switch (value.type) {
        case Types.VARCHAR:
            value.value = rs.getString(value.column);
            break;
        case Types.LONGVARCHAR:
            value.value = rs.getString(value.column);
            break;
        case Types.BIT:
            value.value = rs.getBoolean(value.column);
            break;
        case Types.TINYINT:
            value.value = rs.getByte(value.column);
            break;
        case Types.SMALLINT:
            value.value = rs.getShort(value.column);
            break;
        case Types.INTEGER:
            value.value = rs.getInt(value.column);
            break;
        case Types.BIGINT:
            value.value = rs.getLong(value.column);
            break;
        case Types.REAL:
            value.value = rs.getFloat(value.column);
            break;
        case Types.DOUBLE:
            value.value = rs.getDouble(value.column);
            break;
        case Types.VARBINARY:
            value.value = rs.getBytes(value.column);
            break;
        case Types.DATE:
            value.value = rs.getDate(value.column);
            break;
        case Types.TIMESTAMP:
            value.value = rs.getTimestamp(value.column);
            break;
        case Types.CLOB:
            value.value = rs.getClob(value.column).getCharacterStream();
            break;
        case Types.BLOB:
            value.value = rs.getBlob(value.column).getBinaryStream();
            break;
        default:
            throw new WaarpDatabaseSqlException("Type not supported: " + value.type + " for " + value.column);
        }
    } catch (SQLException e) {
        DbSession.error(e);
        throw new WaarpDatabaseSqlException("Getting values in error: " + value.type + " for " + value.column,
                e);
    }
}

From source file:com.squid.core.domain.operators.ExtendedType.java

public static IDomain computeDomain(int data_type, int size, int scale) {
    switch (data_type) {
    case Types.BOOLEAN:
    case Types.BIT:// on PG systems, this is how a boolean is actually represented by the driver
        return IDomain.BOOLEAN;
    case Types.TINYINT:
    case Types.BIGINT:
    case Types.INTEGER:
    case Types.SMALLINT:
        return IDomain.NUMERIC;
    ///////////////////////////
    case Types.REAL:
    case Types.DOUBLE:
    case Types.FLOAT:
        return IDomain.CONTINUOUS;
    case Types.NUMERIC:
    case Types.DECIMAL:
        return scale > 0 || size == 0 ? IDomain.CONTINUOUS : IDomain.NUMERIC;
    case Types.CHAR:
    case Types.NCHAR:
    case Types.VARCHAR:
    case Types.NVARCHAR:
    case Types.LONGVARCHAR:
    case Types.CLOB:
        return IDomain.STRING;
    ///////////////////////////
    case Types.TIME:
        return IDomain.TIME;
    case Types.DATE:
        return IDomain.DATE;
    case Types.TIMESTAMP:
        return IDomain.TIMESTAMP;
    ///////////////////////////
    default:// w  w  w . ja v  a 2 s.  com
        return IDomain.UNKNOWN;
    }
}

From source file:org.eclipse.ecr.core.storage.sql.extensions.H2Fulltext.java

protected static String asString(Object data, int type) throws SQLException {
    if (data == null) {
        return "";
    }/*from  www  .j av  a2s. c o m*/
    switch (type) {
    case Types.BIT:
    case DataType.TYPE_BOOLEAN:
    case Types.INTEGER:
    case Types.BIGINT:
    case Types.DECIMAL:
    case Types.DOUBLE:
    case Types.FLOAT:
    case Types.NUMERIC:
    case Types.REAL:
    case Types.SMALLINT:
    case Types.TINYINT:
    case Types.DATE:
    case Types.TIME:
    case Types.TIMESTAMP:
    case Types.LONGVARCHAR:
    case Types.CHAR:
    case Types.VARCHAR:
        return data.toString();
    case Types.CLOB:
        try {
            if (data instanceof Clob) {
                data = ((Clob) data).getCharacterStream();
            }
            return IOUtils.readStringAndClose((Reader) data, -1);
        } catch (IOException e) {
            throw Message.convert(e);
        }
    case Types.VARBINARY:
    case Types.LONGVARBINARY:
    case Types.BINARY:
    case Types.JAVA_OBJECT:
    case Types.OTHER:
    case Types.BLOB:
    case Types.STRUCT:
    case Types.REF:
    case Types.NULL:
    case Types.ARRAY:
    case DataType.TYPE_DATALINK:
    case Types.DISTINCT:
        throw new SQLException("Unsupported column data type: " + type);
    default:
        return "";
    }
}

From source file:com.streamsets.pipeline.lib.jdbc.multithread.TableContextUtil.java

public static String getPartitionSizeValidationError(int colType, String column, String partitionSize) {
    switch (colType) {
    case Types.TINYINT:
    case Types.SMALLINT:
    case Types.INTEGER:
        try {/*  ww w.  j a  v a  2 s. c  om*/
            int intVal = Integer.parseInt(partitionSize);
            if (intVal <= 0) {
                return createPartitionSizeValidationError(column, partitionSize, colType,
                        GENERIC_PARTITION_SIZE_GT_ZERO_MSG);
            }
        } catch (NumberFormatException e) {
            return createPartitionSizeValidationError(column, partitionSize, colType, e.getMessage());
        }
        break;
    case Types.BIGINT:
        // TIME, DATE, and TIMESTAMP are represented as long (epoch)
    case Types.TIME:
    case Types.DATE:
    case Types.TIMESTAMP:
        try {
            long longVal = Long.parseLong(partitionSize);
            if (longVal <= 0) {
                return createPartitionSizeValidationError(column, partitionSize, colType,
                        GENERIC_PARTITION_SIZE_GT_ZERO_MSG);
            }
        } catch (NumberFormatException e) {
            return createPartitionSizeValidationError(column, partitionSize, colType, e.getMessage());
        }
        break;
    case Types.FLOAT:
    case Types.REAL:
        try {
            float floatVal = Float.parseFloat(partitionSize);
            if (floatVal <= 0) {
                return createPartitionSizeValidationError(column, partitionSize, colType,
                        GENERIC_PARTITION_SIZE_GT_ZERO_MSG);
            }
        } catch (NumberFormatException e) {
            return createPartitionSizeValidationError(column, partitionSize, colType, e.getMessage());
        }
        break;
    case Types.DOUBLE:
        try {
            double doubleVal = Double.parseDouble(partitionSize);
            if (doubleVal <= 0) {
                return createPartitionSizeValidationError(column, partitionSize, colType,
                        GENERIC_PARTITION_SIZE_GT_ZERO_MSG);
            }
        } catch (NumberFormatException e) {
            return createPartitionSizeValidationError(column, partitionSize, colType, e.getMessage());
        }
        break;
    case Types.NUMERIC:
    case Types.DECIMAL:
        try {
            BigDecimal decimalValue = new BigDecimal(partitionSize);
            if (decimalValue.signum() < 1) {
                return createPartitionSizeValidationError(column, partitionSize, colType,
                        GENERIC_PARTITION_SIZE_GT_ZERO_MSG);
            }
        } catch (NumberFormatException e) {
            return createPartitionSizeValidationError(column, partitionSize, colType, e.getMessage());
        }
        break;
    }
    return null;
}

From source file:org.sakaiproject.webservices.SakaiReport.java

private String getColumnValue(ResultSet rs, int colType, int colIndex) throws SQLException, IOException {
    String value = "";
    switch (colType) {
    case Types.BIT:
    case Types.JAVA_OBJECT:
        value = handleObject(rs.getObject(colIndex));
        break;//from  www.j a  va  2 s  . co  m
    case Types.BOOLEAN:
        boolean b = rs.getBoolean(colIndex);
        value = Boolean.valueOf(b).toString();
        break;
    case NCLOB: // todo : use rs.getNClob
    case Types.CLOB:
        Clob c = rs.getClob(colIndex);
        if (c != null) {
            value = read(c);
        }
        break;
    case Types.BIGINT:
        value = handleLong(rs, colIndex);
        break;
    case Types.DECIMAL:
    case Types.DOUBLE:
    case Types.FLOAT:
    case Types.REAL:
    case Types.NUMERIC:
        value = handleBigDecimal(rs.getBigDecimal(colIndex));
        break;
    case Types.INTEGER:
    case Types.TINYINT:
    case Types.SMALLINT:
        value = handleInteger(rs, colIndex);
        break;
    case Types.DATE:
        value = handleDate(rs, colIndex);
        break;
    case Types.TIME:
        value = handleTime(rs.getTime(colIndex));
        break;
    case Types.TIMESTAMP:
        value = handleTimestamp(rs.getTimestamp(colIndex));
        break;
    case NVARCHAR: // todo : use rs.getNString
    case NCHAR: // todo : use rs.getNString
    case LONGNVARCHAR: // todo : use rs.getNString
    case Types.LONGVARCHAR:
    case Types.VARCHAR:
    case Types.CHAR:
        value = rs.getString(colIndex);
        break;
    case Types.VARBINARY:
    case Types.BINARY:
        value = handleRaw(rs.getBytes(colIndex));
        break;
    default:
        value = "";
    }

    if (value == null) {
        value = "";
    }

    return value;

}

From source file:org.jumpmind.db.platform.AbstractDatabasePlatform.java

protected Object getObjectValue(String value, Column column, BinaryEncoding encoding, boolean useVariableDates,
        boolean fitToColumn) throws DecoderException {
    Object objectValue = value;/* w  w w.j a va  2  s.  c  o  m*/
    int type = column.getMappedTypeCode();
    if ((value == null || (getDdlBuilder().getDatabaseInfo().isEmptyStringNulled() && value.equals("")))
            && column.isRequired() && column.isOfTextType()) {
        objectValue = REQUIRED_FIELD_NULL_SUBSTITUTE;
    }
    if (value != null) {
        if (type == Types.DATE || type == Types.TIMESTAMP || type == Types.TIME) {
            objectValue = parseDate(type, value, useVariableDates);
        } else if (type == Types.CHAR) {
            String charValue = value.toString();
            if ((StringUtils.isBlank(charValue)
                    && getDdlBuilder().getDatabaseInfo().isBlankCharColumnSpacePadded())
                    || (StringUtils.isNotBlank(charValue)
                            && getDdlBuilder().getDatabaseInfo().isNonBlankCharColumnSpacePadded())) {
                objectValue = StringUtils.rightPad(value.toString(), column.getSizeAsInt(), ' ');
            }
        } else if (type == Types.BIGINT) {
            objectValue = parseBigInteger(value);
        } else if (type == Types.INTEGER || type == Types.SMALLINT || type == Types.BIT
                || type == Types.TINYINT) {
            objectValue = parseInteger(value);
        } else if (type == Types.NUMERIC || type == Types.DECIMAL || type == Types.FLOAT || type == Types.DOUBLE
                || type == Types.REAL) {
            objectValue = parseBigDecimal(value);
        } else if (type == Types.BOOLEAN) {
            objectValue = value.equals("1") ? Boolean.TRUE : Boolean.FALSE;
        } else if (!(column.getJdbcTypeName() != null
                && column.getJdbcTypeName().toUpperCase().contains(TypeMap.GEOMETRY))
                && !(column.getJdbcTypeName() != null
                        && column.getJdbcTypeName().toUpperCase().contains(TypeMap.GEOGRAPHY))
                && (type == Types.BLOB || type == Types.LONGVARBINARY || type == Types.BINARY
                        || type == Types.VARBINARY ||
                        // SQLServer ntext type
                        type == -10)) {
            if (encoding == BinaryEncoding.NONE) {
                objectValue = value.getBytes();
            } else if (encoding == BinaryEncoding.BASE64) {
                objectValue = Base64.decodeBase64(value.getBytes());
            } else if (encoding == BinaryEncoding.HEX) {
                objectValue = Hex.decodeHex(value.toCharArray());
            }
        } else if (type == Types.ARRAY) {
            objectValue = createArray(column, value);
        }
    }
    if (objectValue instanceof String) {
        String stringValue = cleanTextForTextBasedColumns((String) objectValue);
        int size = column.getSizeAsInt();
        if (fitToColumn && size > 0 && stringValue.length() > size) {
            stringValue = stringValue.substring(0, size);
        }
        objectValue = stringValue;
    }

    return objectValue;

}

From source file:org.wso2.carbon.event.output.adaptor.mysql.MysqlEventAdaptorType.java

private TableInfo initializeDatabaseTableInfo(String tableName, String executionMode, String updateColumnKeys,
        Object message, OutputEventAdaptorConfiguration adaptorConfig) throws SQLException {
    TableInfo tableInfo = new TableInfo();
    tableInfo.setTableName(tableName);/*from w  w w.j  a  v  a  2  s .co  m*/
    if (resourceBundle.getString(MysqlEventAdaptorConstants.ADAPTOR_MYSQL_EXECUTION_MODE_UPDATE)
            .equalsIgnoreCase(executionMode)) {
        tableInfo.setUpdateMode(true);
    }
    Connection con = null;
    Statement stmt = null;

    try {
        DataSource dataSource = pooledDataSources.get(adaptorConfig.getOutputProperties()
                .get(MysqlEventAdaptorConstants.ADAPTOR_MYSQL_DATASOURCE_NAME));
        if (dataSource == null) {
            CarbonDataSource carbonDataSource = EventAdaptorValueHolder.getDataSourceService()
                    .getDataSource(adaptorConfig.getOutputProperties()
                            .get(MysqlEventAdaptorConstants.ADAPTOR_MYSQL_DATASOURCE_NAME));
            if (carbonDataSource == null) {
                throw new OutputEventAdaptorEventProcessingException(
                        "There is no any data-source found called : " + adaptorConfig.getOutputProperties()
                                .get(MysqlEventAdaptorConstants.ADAPTOR_MYSQL_DATASOURCE_NAME));
            } else {
                dataSource = (DataSource) carbonDataSource.getDSObject();
                pooledDataSources.put(adaptorConfig, dataSource);
            }
        }

        con = dataSource.getConnection();
        String databaseName = con.getCatalog();
        tableInfo.setDatabaseName(databaseName);

        // create the table.
        StringBuilder statementBuilder = new StringBuilder("CREATE TABLE IF NOT EXISTS ");
        statementBuilder.append(databaseName + "." + tableName);
        statementBuilder.append(" (");
        boolean appendComma = false;
        for (Map.Entry<String, Object> entry : (((Map<String, Object>) message).entrySet())) {
            if (appendComma) {
                statementBuilder.append(",");
            } else {
                appendComma = true;
            }
            statementBuilder.append(entry.getKey()).append("  ");
            if (entry.getValue() instanceof Integer) {
                statementBuilder.append("INT");
            } else if (entry.getValue() instanceof Long) {
                statementBuilder.append("BIGINT");
            } else if (entry.getValue() instanceof Float) {
                statementBuilder.append("FLOAT");
            } else if (entry.getValue() instanceof Double) {
                statementBuilder.append("DOUBLE");
            } else if (entry.getValue() instanceof String) {
                statementBuilder.append("VARCHAR(255)");
            } else if (entry.getValue() instanceof Boolean) {
                statementBuilder.append("BOOL");
            }
        }
        statementBuilder.append(")");

        stmt = con.createStatement();
        stmt.execute("CREATE SCHEMA IF NOT EXISTS " + databaseName);
        stmt.executeUpdate(statementBuilder.toString());

        ArrayList<Attribute> tableInsertColumnList = new ArrayList<Attribute>();
        statementBuilder = new StringBuilder("INSERT INTO ");
        statementBuilder.append(databaseName + "." + tableName);
        statementBuilder.append(" ( ");

        StringBuilder valuePositionsBuilder = new StringBuilder("");

        appendComma = false;
        DatabaseMetaData databaseMetaData = con.getMetaData();
        ResultSet rs = databaseMetaData.getColumns(databaseName, null, tableName, null);
        while (rs.next()) {
            AttributeType type = null;
            int colType = rs.getInt("DATA_TYPE");
            switch (colType) {
            case Types.VARCHAR:
                type = AttributeType.STRING;
                break;
            case Types.INTEGER:
                type = AttributeType.INT;
                break;
            case Types.BIGINT:
                type = AttributeType.LONG;
                break;
            case Types.DOUBLE:
                type = AttributeType.DOUBLE;
                break;
            case Types.FLOAT:
                type = AttributeType.FLOAT;
                break;
            case Types.TINYINT:
            case Types.BOOLEAN:
            case MysqlEventAdaptorConstants.TINYINT_MYSQL_VALUE:
                type = AttributeType.BOOL;
                break;

            }
            Attribute attribute = new Attribute(rs.getString("COLUMN_NAME"), type);
            tableInsertColumnList.add(attribute);

            if (appendComma) {
                statementBuilder.append(",");
                valuePositionsBuilder.append(",");
            } else {
                appendComma = true;
            }
            statementBuilder.append(attribute.getName());
            valuePositionsBuilder.append("?");
        }
        statementBuilder.append(") VALUES (");
        statementBuilder.append(valuePositionsBuilder.toString());
        statementBuilder.append(")");
        tableInfo.setPreparedInsertStatement(statementBuilder.toString());
        tableInfo.setInsertColumnOrder(tableInsertColumnList);

        if (executionMode.equalsIgnoreCase(
                resourceBundle.getString(MysqlEventAdaptorConstants.ADAPTOR_MYSQL_EXECUTION_MODE_UPDATE))) {

            // existence check query.
            StringBuilder existenceQueryBuilder = new StringBuilder("SELECT 1 FROM ");
            existenceQueryBuilder.append(databaseName + "." + tableName);
            existenceQueryBuilder.append(" WHERE ");
            String[] queryAttributes = updateColumnKeys.trim().split(",");
            ArrayList<Attribute> queryAttributeList = new ArrayList<Attribute>(queryAttributes.length);

            for (int i = 0; i < queryAttributes.length; i++) {
                if (i > 0) {
                    existenceQueryBuilder.append(" AND ");
                }
                existenceQueryBuilder.append(queryAttributes[i]);
                existenceQueryBuilder.append(" = ? ");
                for (Attribute at : tableInfo.getInsertColumnOrder()) {
                    if (queryAttributes[i].equalsIgnoreCase(at.getName())) {
                        queryAttributeList.add(at);
                        break;
                    }
                }
            }
            tableInfo.setExistenceCheckColumnOrder(queryAttributeList);
            tableInfo.setPreparedExistenceCheckStatement(existenceQueryBuilder.toString());

            // update query.
            StringBuilder updateQueryBuilder = new StringBuilder("UPDATE  ");
            ArrayList<Attribute> updateAttributes = new ArrayList<Attribute>();
            updateQueryBuilder.append(tableInfo.getDatabaseName() + "." + tableInfo.getTableName());
            updateQueryBuilder.append(" SET ");
            appendComma = false;
            for (Attribute at : tableInfo.getInsertColumnOrder()) {
                if (!tableInfo.getExistenceCheckColumnOrder().contains(at)) {
                    if (appendComma) {
                        updateQueryBuilder.append(" , ");
                    }
                    updateQueryBuilder.append(at.getName());
                    updateQueryBuilder.append(" = ? ");
                    updateAttributes.add(at);
                    appendComma = true;
                }
            }
            updateQueryBuilder.append(" WHERE ");
            boolean appendAnd = false;
            for (Attribute at : tableInfo.getExistenceCheckColumnOrder()) {
                if (appendAnd) {
                    updateQueryBuilder.append(" AND ");
                }
                updateQueryBuilder.append(at.getName());
                updateQueryBuilder.append(" = ? ");
                updateAttributes.add(at);
                appendAnd = true;
            }
            tableInfo.setUpdateColumnOrder(updateAttributes);
            tableInfo.setPreparedUpdateStatement(updateQueryBuilder.toString());

        }
        return tableInfo;
    } catch (SQLException e) {
        pooledDataSources.remove(adaptorConfig.getOutputProperties()
                .get(MysqlEventAdaptorConstants.ADAPTOR_MYSQL_DATASOURCE_NAME));
        log.error("error while initializing the table", e);
    } catch (DataSourceException e) {
        pooledDataSources.remove(adaptorConfig.getOutputProperties()
                .get(MysqlEventAdaptorConstants.ADAPTOR_MYSQL_DATASOURCE_NAME));
        log.error("error while accessing the datasource:", e);
    } finally {
        cleanupConnections(stmt, con);
    }
    return null;
}