List of usage examples for java.sql Types NUMERIC
int NUMERIC
To view the source code for java.sql Types NUMERIC.
Click Source Link
The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type NUMERIC
.
From source file:org.apache.cayenne.migration.MigrationGenerator.java
protected boolean isFixedPoint(int type) { return type == Types.DECIMAL || type == Types.NUMERIC; }
From source file:architecture.ee.web.logo.dao.jdbc.JdbcLogoImageDao.java
public int getLogoImageCount(int objectType, long objectId) { return getExtendedJdbcTemplate().queryForInt( getBoundSql("ARCHITECTURE_WEB.COUNT_LOGO_IMAGE_BY_OBJECT_TYPE_AND_OBJECT_ID").getSql(), new SqlParameterValue(Types.NUMERIC, objectType), new SqlParameterValue(Types.NUMERIC, objectId)); }
From source file:nl.nn.adapterframework.statistics.jdbc.StatisticsKeeperStore.java
private void applyParam(PreparedStatement stmt, int pos, long value) throws SQLException { if (trace && log.isDebugEnabled()) log.debug("pos [" + pos + "] set long param [" + value + "]"); if (value == Long.MAX_VALUE) { stmt.setNull(pos, Types.NUMERIC); } else {/*from w w w . j ava2 s .co m*/ stmt.setLong(pos, value); } }
From source file:org.jumpmind.symmetric.service.impl.OutgoingBatchService.java
public void updateOutgoingBatch(ISqlTransaction transaction, OutgoingBatch outgoingBatch) { outgoingBatch.setLastUpdatedTime(new Date()); outgoingBatch.setLastUpdatedHostName(clusterService.getServerId()); transaction.prepareAndExecute(getSql("updateOutgoingBatchSql"), new Object[] { outgoingBatch.getStatus().name(), outgoingBatch.getLoadId(), outgoingBatch.isExtractJobFlag() ? 1 : 0, outgoingBatch.isLoadFlag() ? 1 : 0, outgoingBatch.isErrorFlag() ? 1 : 0, outgoingBatch.getByteCount(), outgoingBatch.getExtractCount(), outgoingBatch.getSentCount(), outgoingBatch.getLoadCount(), outgoingBatch.getDataEventCount(), outgoingBatch.getReloadEventCount(), outgoingBatch.getInsertEventCount(), outgoingBatch.getUpdateEventCount(), outgoingBatch.getDeleteEventCount(), outgoingBatch.getOtherEventCount(), outgoingBatch.getIgnoreCount(), outgoingBatch.getRouterMillis(), outgoingBatch.getNetworkMillis(), outgoingBatch.getFilterMillis(), outgoingBatch.getLoadMillis(), outgoingBatch.getExtractMillis(), outgoingBatch.getSqlState(), outgoingBatch.getSqlCode(), FormatUtils.abbreviateForLogging(outgoingBatch.getSqlMessage()), outgoingBatch.getFailedDataId(), outgoingBatch.getLastUpdatedHostName(), outgoingBatch.getLastUpdatedTime(), outgoingBatch.getBatchId(), outgoingBatch.getNodeId() }, new int[] { Types.CHAR, Types.BIGINT, Types.NUMERIC, Types.NUMERIC, Types.NUMERIC, Types.BIGINT, Types.BIGINT, Types.BIGINT, Types.BIGINT, Types.BIGINT, Types.BIGINT, Types.BIGINT, Types.BIGINT, Types.BIGINT, Types.BIGINT, Types.BIGINT, Types.BIGINT, Types.BIGINT, Types.BIGINT, Types.BIGINT, Types.BIGINT, Types.VARCHAR, Types.NUMERIC, Types.VARCHAR, Types.BIGINT, Types.VARCHAR, Types.TIMESTAMP, symmetricDialect.getSqlTypeForIds(), Types.VARCHAR }); }
From source file:com.squid.core.domain.operators.ExtendedType.java
/** * compute a type "order" that can be used to compare types and promote types. * The order is a couple (x,y), where x represent a family type (string,date,numbers) and y an order in that family * A type should be promoted to the higher order. * @return/*from ww w. j ava 2 s. c om*/ */ public int[] computeTypeOrder() { switch (getDataType()) { case Types.BIT: return new int[] { NUMBER_ORDER, 0 }; case Types.BOOLEAN: return new int[] { NUMBER_ORDER, 1 }; case Types.TINYINT: return new int[] { NUMBER_ORDER, 2 }; case Types.SMALLINT: return new int[] { NUMBER_ORDER, 3 }; case Types.INTEGER: return new int[] { NUMBER_ORDER, 4 }; case Types.BIGINT: return new int[] { NUMBER_ORDER, 5 }; /////////////////////////// case Types.REAL: return new int[] { NUMBER_ORDER, 6 }; case Types.DOUBLE: case Types.FLOAT: return new int[] { NUMBER_ORDER, 7 }; case Types.DECIMAL: return new int[] { NUMBER_ORDER, 8 }; case Types.NUMERIC: return new int[] { NUMBER_ORDER, 9 }; ////////////////////////// case Types.CHAR: return new int[] { STRING_ORDER, 0 }; case Types.VARCHAR: return new int[] { STRING_ORDER, 1 }; case Types.LONGVARCHAR: return new int[] { STRING_ORDER, 2 }; case Types.CLOB: return new int[] { STRING_ORDER, 3 }; /////////////////////////// case Types.TIME: return new int[] { DATE_ORDER, 1 }; case Types.DATE: return new int[] { DATE_ORDER, 2 }; case Types.TIMESTAMP: return new int[] { DATE_ORDER, 3 }; case CustomTypes.INTERVAL: return new int[] { DATE_ORDER, 4 }; /////////////////////////// default: return new int[] { UNKNOWN_ORDER, 0 }; } }
From source file:org.apache.ddlutils.PlatformInfo.java
/** * Creates a new platform info object./* www . j a v a 2 s. co m*/ */ public PlatformInfo() { _typesWithNullDefault.add(new Integer(Types.CHAR)); _typesWithNullDefault.add(new Integer(Types.VARCHAR)); _typesWithNullDefault.add(new Integer(Types.LONGVARCHAR)); _typesWithNullDefault.add(new Integer(Types.CLOB)); _typesWithNullDefault.add(new Integer(Types.BINARY)); _typesWithNullDefault.add(new Integer(Types.VARBINARY)); _typesWithNullDefault.add(new Integer(Types.LONGVARBINARY)); _typesWithNullDefault.add(new Integer(Types.BLOB)); _typesWithSize.add(new Integer(Types.CHAR)); _typesWithSize.add(new Integer(Types.VARCHAR)); _typesWithSize.add(new Integer(Types.BINARY)); _typesWithSize.add(new Integer(Types.VARBINARY)); _typesWithPrecisionAndScale.add(new Integer(Types.DECIMAL)); _typesWithPrecisionAndScale.add(new Integer(Types.NUMERIC)); _supportedOnUpdateActions.addAll(CascadeActionEnum.getEnumList()); _supportedOnDeleteActions.addAll(CascadeActionEnum.getEnumList()); }
From source file:org.exist.xquery.modules.oracle.ExecuteFunction.java
@Override public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException { if (args.length == 5 || args.length == 6) { // was a connection and PL/SQL statement specified? if (args[0].isEmpty() || args[1].isEmpty()) { return (Sequence.EMPTY_SEQUENCE); }//ww w.ja v a2 s . c om // get the Connection long connectionUID = ((IntegerValue) args[0].itemAt(0)).getLong(); Connection connection = SQLModule.retrieveConnection(context, connectionUID); if (connection == null) { return (Sequence.EMPTY_SEQUENCE); } // get the PL/SQL statement String plSql = args[1].getStringValue(); // get the input parameters (if any) Element parameters = null; if (!args[2].isEmpty()) { parameters = (Element) args[2].itemAt(0); } // was a result set position specified? int resultSetPos = 0; if (!args[3].isEmpty()) { resultSetPos = ((IntegerValue) args[3].itemAt(0)).getInt(); } boolean haveReturnCode = false; int plSqlSuccess = 1; // default value of 1 for success if (args.length == 6) { // a return code is expected so what is the value indicating success? plSqlSuccess = ((IntegerValue) args[5].itemAt(0)).getInt(); haveReturnCode = true; } CallableStatement statement = null; ResultSet resultSet = null; try { MemTreeBuilder builder = context.getDocumentBuilder(); int iRow = 0; statement = connection.prepareCall(plSql); if (haveReturnCode) { statement.registerOutParameter(1, Types.NUMERIC); } if (resultSetPos != 0) { statement.registerOutParameter(resultSetPos, OracleTypes.CURSOR); } if (!args[2].isEmpty()) { setParametersOnPreparedStatement(statement, parameters); } statement.execute(); if (haveReturnCode) { int returnCode = statement.getInt(1); if (returnCode != plSqlSuccess) { LOG.error(plSql + " failed [" + returnCode + "]"); return (Sequence.EMPTY_SEQUENCE); } } if (resultSetPos != 0) { // iterate through the result set building an XML document builder.startDocument(); builder.startElement(new QName("result", OracleModule.NAMESPACE_URI, OracleModule.PREFIX), null); builder.addAttribute(new QName("count", null, null), String.valueOf(-1)); resultSet = (ResultSet) statement.getObject(resultSetPos); ResultSetMetaData rsmd = resultSet.getMetaData(); int iColumns = rsmd.getColumnCount(); while (resultSet.next()) { builder.startElement(new QName("row", OracleModule.NAMESPACE_URI, OracleModule.PREFIX), null); builder.addAttribute(new QName("index", null, null), String.valueOf(resultSet.getRow())); // get each tuple in the row for (int i = 0; i < iColumns; i++) { String columnName = rsmd.getColumnLabel(i + 1); if (columnName != null) { String colValue = resultSet.getString(i + 1); String colElement = "field"; if (((BooleanValue) args[4].itemAt(0)).effectiveBooleanValue() && columnName.length() > 0) { // use column names as the XML node /** * Spaces in column names are replaced with * underscore's */ colElement = SQLUtils.escapeXmlAttr(columnName.replace(' ', '_')); } builder.startElement( new QName(colElement, OracleModule.NAMESPACE_URI, OracleModule.PREFIX), null); if (!((BooleanValue) args[4].itemAt(0)).effectiveBooleanValue() || columnName.length() <= 0) { String name; if (columnName.length() > 0) { name = SQLUtils.escapeXmlAttr(columnName); } else { name = "Column: " + String.valueOf(i + 1); } builder.addAttribute(new QName("name", null, null), name); } builder.addAttribute( new QName("type", OracleModule.NAMESPACE_URI, OracleModule.PREFIX), rsmd.getColumnTypeName(i + 1)); builder.addAttribute(new QName("type", Namespaces.SCHEMA_NS, "xs"), Type.getTypeName(SQLUtils.sqlTypeToXMLType(rsmd.getColumnType(i + 1)))); if (resultSet.wasNull()) { // Add a null indicator attribute if the value was SQL Null builder.addAttribute( new QName("null", OracleModule.NAMESPACE_URI, OracleModule.PREFIX), "true"); } if (colValue != null) { builder.characters(SQLUtils.escapeXmlText(colValue)); } builder.endElement(); } } builder.endElement(); iRow++; } builder.endElement(); // Change the root element count attribute to have the correct value NodeValue node = (NodeValue) builder.getDocument().getDocumentElement(); Node count = node.getNode().getAttributes().getNamedItem("count"); if (count != null) { count.setNodeValue(String.valueOf(iRow)); } builder.endDocument(); // return the XML result set return (node); } else { // there was no result set so just return an empty sequence return (Sequence.EMPTY_SEQUENCE); } } catch (SQLException sqle) { LOG.error("oracle:execute() Caught SQLException \"" + sqle.getMessage() + "\" for PL/SQL: \"" + plSql + "\"", sqle); //return details about the SQLException MemTreeBuilder builder = context.getDocumentBuilder(); builder.startDocument(); builder.startElement(new QName("exception", OracleModule.NAMESPACE_URI, OracleModule.PREFIX), null); boolean recoverable = false; if (sqle instanceof SQLRecoverableException) { recoverable = true; } builder.addAttribute(new QName("recoverable", null, null), String.valueOf(recoverable)); builder.startElement(new QName("state", OracleModule.NAMESPACE_URI, OracleModule.PREFIX), null); String sqlState = sqle.getSQLState(); if (sqlState != null) { builder.characters(sqle.getSQLState()); } else { builder.characters("null"); } builder.endElement(); builder.startElement(new QName("message", OracleModule.NAMESPACE_URI, OracleModule.PREFIX), null); builder.characters(sqle.getMessage()); builder.endElement(); builder.startElement(new QName("stack-trace", OracleModule.NAMESPACE_URI, OracleModule.PREFIX), null); ByteArrayOutputStream bufStackTrace = new ByteArrayOutputStream(); sqle.printStackTrace(new PrintStream(bufStackTrace)); builder.characters(new String(bufStackTrace.toByteArray())); builder.endElement(); builder.startElement(new QName("oracle", OracleModule.NAMESPACE_URI, OracleModule.PREFIX), null); builder.characters(SQLUtils.escapeXmlText(plSql)); builder.endElement(); int line = getLine(); int column = getColumn(); builder.startElement(new QName("xquery", OracleModule.NAMESPACE_URI, OracleModule.PREFIX), null); builder.addAttribute(new QName("line", null, null), String.valueOf(line)); builder.addAttribute(new QName("column", null, null), String.valueOf(column)); builder.endElement(); builder.endElement(); builder.endDocument(); return (NodeValue) builder.getDocument().getDocumentElement(); } finally { release(connection, statement, resultSet); } } else { throw new XPathException("Invalid number of arguments [" + args.length + "]"); } }
From source file:org.kuali.core.db.torque.KualiTorqueJDBCTransformTask.java
/** * Generates an XML database schema from JDBC metadata. * /*from w ww.j av a 2 s .c o m*/ * @throws Exception * a generic exception. */ public void generateXML() throws Exception { // Load the database Driver. Class.forName(dbDriver); log("DB driver sucessfuly instantiated"); Connection con = null; try { // Attempt to connect to a database. Properties p = new Properties(); p.setProperty("user", dbUser); p.setProperty("password", dbPassword); p.setProperty("oracle.jdbc.mapDateToTimestamp", "false"); // workaround for change in 11g JDBC driver con = DriverManager.getConnection(dbUrl, p); log("DB connection established"); Platform platform = PlatformFactory.getPlatformFor(dbType); // Get the database Metadata. DatabaseMetaData dbMetaData = con.getMetaData(); databaseNode = doc.createElement("database"); databaseNode.setAttribute("name", "kuali"); // JHK added naming method databaseNode.setAttribute("defaultJavaNamingMethod", "nochange"); if (processTables) { List<String> tableList = platform.getTableNames(dbMetaData, dbSchema); // ensure all are upper case before exporting tableList = upperCaseList(tableList); // ensure sorting is consistent (not DB-dependent) Collections.sort(tableList); for (String curTable : tableList) { if (!tableNameRegexPattern.matcher(curTable).matches()) { log("Skipping table: " + curTable); continue; } if (StringUtils.isNotBlank(tableNameExcludeRegex) && tableNameExcludeRegexPattern.matcher(curTable).matches()) { log("Skipping table: " + curTable); continue; } log("Processing table: " + curTable); Element table = doc.createElement("table"); table.setAttribute("name", curTable.toUpperCase()); // Add Columns. // TableMap tblMap = dbMap.getTable(curTable); List columns = getColumns(dbMetaData, curTable); List<String> primKeys = platform.getPrimaryKeys(dbMetaData, dbSchema, curTable); Map<String, Object[]> foreignKeys = getForeignKeys(dbMetaData, curTable); // Set the primary keys. primaryKeys = new HashMap<String, String>(); for (int k = 0; k < primKeys.size(); k++) { String curPrimaryKey = (String) primKeys.get(k); primaryKeys.put(curPrimaryKey, curPrimaryKey); } for (int j = 0; j < columns.size(); j++) { List col = (List) columns.get(j); String name = (String) col.get(0); Integer jdbcType = ((Integer) col.get(1)); int size = ((Integer) col.get(2)).intValue(); int scale = ((Integer) col.get(5)).intValue(); // From DatabaseMetaData.java // // Indicates column might not allow NULL values. Huh? // Might? Boy, that's a definitive answer. /* int columnNoNulls = 0; */ // Indicates column definitely allows NULL values. /* int columnNullable = 1; */ // Indicates NULLABILITY of column is unknown. /* int columnNullableUnknown = 2; */ Integer nullType = (Integer) col.get(3); String defValue = (String) col.get(4); Element column = doc.createElement("column"); column.setAttribute("name", name); ; column.setAttribute("type", platform.getTorqueColumnType(jdbcType)); // TypeMap.getTorqueType( type ).getName() ); if (size > 0 && (jdbcType.intValue() == Types.CHAR || jdbcType.intValue() == Types.VARCHAR || jdbcType.intValue() == Types.DECIMAL || jdbcType.intValue() == Types.NUMERIC)) { column.setAttribute("size", String.valueOf(size)); } if (scale > 0 && (jdbcType.intValue() == Types.DECIMAL || jdbcType.intValue() == Types.NUMERIC)) { column.setAttribute("scale", String.valueOf(scale)); } if (primaryKeys.containsKey(name)) { column.setAttribute("primaryKey", "true"); // JHK: protect MySQL from excessively long column in the PK //System.out.println( curTable + "." + name + " / " + size ); if (column.getAttribute("size") != null && size > 765) { log("updating column " + curTable + "." + name + " length from " + size + " to 255"); column.setAttribute("size", "255"); } } else { if (nullType.intValue() == DatabaseMetaData.columnNoNulls) { column.setAttribute("required", "true"); } } if (StringUtils.isNotEmpty(defValue)) { defValue = platform.getColumnDefaultValue(platform.getTorqueColumnType(jdbcType), defValue); if (StringUtils.isNotEmpty(defValue)) { column.setAttribute("default", defValue); } } table.appendChild(column); } List<String> foreignKeyNames = new ArrayList<String>(foreignKeys.keySet()); Collections.sort(foreignKeyNames); // Foreign keys for this table. for (String fkName : foreignKeyNames) { Element fk = doc.createElement("foreign-key"); fk.setAttribute("name", fkName.toUpperCase()); Object[] forKey = foreignKeys.get(fkName); String foreignKeyTable = (String) forKey[0]; List refs = (List) forKey[1]; fk.setAttribute("foreignTable", foreignKeyTable.toUpperCase()); String onDelete = (String) forKey[2]; // gmcgrego - just adding onDelete if it's cascade so as not to affect kfs behavior if (onDelete == "cascade") { fk.setAttribute("onDelete", onDelete); } for (int m = 0; m < refs.size(); m++) { Element ref = doc.createElement("reference"); String[] refData = (String[]) refs.get(m); ref.setAttribute("local", refData[0]); ref.setAttribute("foreign", refData[1]); fk.appendChild(ref); } table.appendChild(fk); } List<TableIndex> indexes = getIndexes(dbMetaData, curTable); Collections.sort(indexes, new Comparator<TableIndex>() { public int compare(TableIndex o1, TableIndex o2) { return o1.name.compareTo(o2.name); } }); for (TableIndex idx : indexes) { if (foreignKeyNames.contains(idx.name)) { log(idx.name + " is also a foreign key, skipping"); continue; } String tagName = idx.unique ? "unique" : "index"; Element index = doc.createElement(tagName); index.setAttribute("name", idx.name.toUpperCase()); for (String colName : idx.columns) { Element col = doc.createElement(tagName + "-column"); col.setAttribute("name", colName); index.appendChild(col); } table.appendChild(index); } databaseNode.appendChild(table); } } if (processViews) { log("Getting view list..."); List<String> viewNames = platform.getViewNames(dbMetaData, dbSchema); log("Found " + viewNames.size() + " views."); viewNames = upperCaseList(viewNames); Collections.sort(viewNames); for (String viewName : viewNames) { if (!tableNameRegexPattern.matcher(viewName).matches()) { log("Skipping view: " + viewName); continue; } Element view = doc.createElement("view"); view.setAttribute("name", viewName.toUpperCase()); /* * <view name="" viewdefinition="" /> * */ String definition = platform.getViewDefinition(dbMetaData.getConnection(), dbSchema, viewName); definition = definition.replaceAll("\0", ""); view.setAttribute("viewdefinition", definition); databaseNode.appendChild(view); } } if (processSequences) { log("Getting sequence list..."); List<String> sequenceNames = platform.getSequenceNames(dbMetaData, dbSchema); log("Found " + sequenceNames.size() + " sequences."); sequenceNames = upperCaseList(sequenceNames); Collections.sort(sequenceNames); for (String sequenceName : sequenceNames) { if (!tableNameRegexPattern.matcher(sequenceName).matches()) { log("Skipping sequence: " + sequenceName); continue; } Element sequence = doc.createElement("sequence"); sequence.setAttribute("name", sequenceName.toUpperCase()); /* * <view name="" nextval="" /> * */ Long nextVal = platform.getSequenceNextVal(dbMetaData.getConnection(), dbSchema, sequenceName); sequence.setAttribute("nextval", nextVal.toString()); databaseNode.appendChild(sequence); } doc.appendChild(databaseNode); } } finally { if (con != null) { con.close(); con = null; } } }
From source file:com.flexive.ejb.beans.UserGroupEngineBean.java
/** * {@inheritDoc}/* ww w. ja v a2 s.c om*/ */ @Override @TransactionAttribute(TransactionAttributeType.REQUIRED) public long create(String name, String color, long mandatorId) throws FxApplicationException { final UserTicket ticket = FxContext.getUserTicket(); // Permission checks try { if (!ticket.isGlobalSupervisor()) { if (ticket.getMandatorId() != mandatorId) { throw new FxNoAccessException("ex.usergroup.create.foreignMandator"); } if (!ticket.isInRole(Role.MandatorSupervisor)) FxPermissionUtils.checkRole(ticket, Role.AccountManagement); } } catch (FxNoAccessException nae) { if (LOG.isInfoEnabled()) LOG.info(nae); throw nae; } Connection con = null; Statement stmt = null; PreparedStatement ps = null; String sql = null; try { // Sanity checks color = FxFormatUtils.processColorString("color", color); checkName(name); // Obtain a database connection con = Database.getDbConnection(); // Obtain a new id long groupId = seq.getId(FxSystemSequencer.GROUP); // Create the new group sql = "INSERT INTO " + TBL_USERGROUPS + " " + "(ID,MANDATOR,AUTOMANDATOR,ISSYSTEM,NAME,COLOR,CREATED_BY,CREATED_AT,MODIFIED_BY,MODIFIED_AT) VALUES (" + "?,?,?,?,?,?,?,?,?,?)"; final long NOW = System.currentTimeMillis(); ps = con.prepareStatement(sql); ps.setLong(1, groupId); ps.setLong(2, mandatorId); ps.setNull(3, java.sql.Types.NUMERIC); ps.setBoolean(4, false); ps.setString(5, name); ps.setString(6, color); ps.setLong(7, ticket.getUserId()); ps.setLong(8, NOW); ps.setLong(9, ticket.getUserId()); ps.setLong(10, NOW); ps.executeUpdate(); StructureLoader.updateUserGroups(FxContext.get().getDivisionId(), loadAll(-1)); // Return the new id return groupId; } catch (SQLException exc) { final boolean uniqueConstraintViolation = StorageManager.isUniqueConstraintViolation(exc); EJBUtils.rollback(ctx); if (uniqueConstraintViolation) { FxEntryExistsException eee = new FxEntryExistsException("ex.usergroup.create.groupExists", name); if (LOG.isInfoEnabled()) LOG.info(eee); throw eee; } else { FxCreateException ce = new FxCreateException(exc, "ex.usergroup.sqlError", exc.getMessage(), sql); LOG.error(ce); throw ce; } } finally { Database.closeObjects(UserGroupEngineBean.class, null, ps); Database.closeObjects(UserGroupEngineBean.class, con, stmt); } }
From source file:org.seasar.dbflute.logic.replaceschema.loaddata.impl.DfAbsractDataWriter.java
protected boolean processNull(String tableName, String columnName, Object value, PreparedStatement ps, int bindCount, Map<String, DfColumnMeta> columnInfoMap) throws SQLException { if (!isNullValue(value)) { return false; }//from www . j av a2 s.c o m Map<String, Integer> cacheMap = _nullTypeCacheMap.get(tableName); if (cacheMap == null) { cacheMap = StringKeyMap.createAsFlexibleOrdered(); _nullTypeCacheMap.put(tableName, cacheMap); } final Integer cachedType = cacheMap.get(columnName); if (cachedType != null) { // cache hit ps.setNull(bindCount, cachedType); // basically no exception return true; } final DfColumnMeta columnInfo = columnInfoMap.get(columnName); if (columnInfo != null) { // use mapped type at first final String mappedJdbcType = _columnHandler.getColumnJdbcType(columnInfo); final Integer mappedJdbcDefValue = TypeMap.getJdbcDefValueByJdbcType(mappedJdbcType); try { ps.setNull(bindCount, mappedJdbcDefValue); cacheMap.put(columnName, mappedJdbcDefValue); } catch (SQLException e) { // retry by plain type final int plainJdbcDefValue = columnInfo.getJdbcDefValue(); try { ps.setNull(bindCount, plainJdbcDefValue); cacheMap.put(columnName, plainJdbcDefValue); } catch (SQLException ignored) { final ExceptionMessageBuilder br = new ExceptionMessageBuilder(); br.addNotice("Failed to execute setNull(bindCount, jdbcDefValue)."); br.addItem("Column"); br.addElement(tableName + "." + columnName); br.addElement(columnInfo.toString()); br.addItem("Mapped JDBC Type"); br.addElement(mappedJdbcType); br.addItem("First JDBC Def-Value"); br.addElement(mappedJdbcDefValue); br.addItem("Retry JDBC Def-Value"); br.addElement(plainJdbcDefValue); br.addItem("Retry Message"); br.addElement(ignored.getMessage()); String msg = br.buildExceptionMessage(); throw new DfJDBCException(msg, e); } } } else { // basically no way Integer tryType = Types.VARCHAR; // as default try { ps.setNull(bindCount, tryType); cacheMap.put(columnName, tryType); } catch (SQLException e) { tryType = Types.NUMERIC; try { ps.setNull(bindCount, tryType); cacheMap.put(columnName, tryType); } catch (SQLException ignored) { tryType = Types.TIMESTAMP; try { ps.setNull(bindCount, tryType); cacheMap.put(columnName, tryType); } catch (SQLException iignored) { tryType = Types.OTHER; try { ps.setNull(bindCount, tryType); // last try cacheMap.put(columnName, tryType); } catch (SQLException iiignored) { throw e; } } } } } return true; }