List of usage examples for java.sql Types NULL
int NULL
To view the source code for java.sql Types NULL.
Click Source Link
The constant in the Java programming language that identifies the generic SQL value NULL
.
From source file:Main.java
public static String getCloverTypeFromJdbcType(int jdbcDataType) { switch (jdbcDataType) { case Types.DATE: case Types.TIME: case Types.TIMESTAMP: return "date"; case Types.ARRAY: case Types.BINARY: case Types.DATALINK: case Types.BLOB: case Types.DISTINCT: case Types.JAVA_OBJECT: case Types.NULL: case Types.OTHER: case Types.REF: case Types.STRUCT: case Types.VARBINARY: case Types.LONGVARBINARY: System.out.println("Outputting cbyte for Type: " + jdbcDataType); return "cbyte"; case Types.BIT: case Types.BOOLEAN: return "boolean"; case Types.DECIMAL: case Types.DOUBLE: case Types.FLOAT: case Types.NUMERIC: case Types.REAL: return "numeric"; case Types.INTEGER: case Types.SMALLINT: return "integer"; case Types.BIGINT: return "long"; case Types.CHAR: case Types.VARCHAR: case Types.CLOB: case Types.LONGVARCHAR: return "string"; }//w w w .j a v a 2 s . com System.out.println("Outputting string for unknown Type: " + jdbcDataType); return "string"; }
From source file:org.pentaho.reporting.engine.classic.core.modules.misc.tablemodel.TypeMapper.java
private static Class mapSQLType(final int t) { switch (t) {/*w w w . j a v a 2s .co m*/ case Types.ARRAY: return Object[].class; case Types.BIGINT: return Long.class; case Types.BINARY: return byteArrayClass; case Types.BIT: return Boolean.class; case Types.BLOB: return Blob.class; case Types.BOOLEAN: // Types.BOOLEAN was not part of JDK1.2.2 return Boolean.class; case Types.CHAR: return String.class; case Types.CLOB: return Clob.class; case Types.DATALINK: // Types.DATALINK was not part of JDK 1.2.2 return URL.class; case Types.DATE: return java.sql.Date.class; case Types.DECIMAL: return java.math.BigDecimal.class; case Types.DISTINCT: return Object.class; case Types.DOUBLE: return Double.class; case Types.FLOAT: return Double.class; case Types.INTEGER: return Integer.class; case Types.JAVA_OBJECT: return Object.class; case Types.LONGVARBINARY: return byteArrayClass; case Types.LONGVARCHAR: return String.class; case Types.NCLOB: return NClob.class; case Types.NULL: return Object.class; case Types.NUMERIC: return java.math.BigDecimal.class; case Types.NCHAR: case Types.NVARCHAR: case Types.LONGNVARCHAR: return String.class; case Types.OTHER: return Object.class; case Types.REAL: return Float.class; case Types.REF: return Ref.class; case Types.ROWID: return RowId.class; case Types.SMALLINT: return Short.class; case Types.STRUCT: return Struct.class; case Types.SQLXML: return SQLXML.class; case Types.TIME: return Time.class; case Types.TIMESTAMP: return Timestamp.class; case Types.TINYINT: return Byte.class; case Types.VARBINARY: return byteArrayClass; case Types.VARCHAR: return String.class; default: return Object.class; } }
From source file:com.nabla.wapp.server.json.SqlColumn.java
public SqlColumn(String label, int type, int length) { this.label = label; this.type = (type == Types.TINYINT) ? (length == 1 ? Types.BOOLEAN : type) : type; if (log.isDebugEnabled()) { String s;/*from w w w. j av a 2 s. co m*/ switch (this.type) { case Types.BIGINT: case Types.INTEGER: case Types.SMALLINT: case Types.TINYINT: s = "INTEGER"; break; case Types.BOOLEAN: case Types.BIT: s = "BOOLEAN"; break; case Types.DATE: s = "DATE"; break; case Types.TIMESTAMP: s = "TIMESTAMP"; break; case Types.DOUBLE: s = "DOUBLE"; break; case Types.FLOAT: s = "FLOAT"; break; case Types.NULL: s = "NULL"; break; default: s = "STRING"; break; } log.debug("column '" + this.label + "' " + s); } }
From source file:com.yahoo.elide.datastores.hibernate3.usertypes.JsonType.java
/** * {@inheritDoc}/* w w w. ja v a2s . com*/ */ @Override public void nullSafeSet(PreparedStatement preparedStatement, Object value, int index) throws HibernateException, SQLException { if (value == null) { preparedStatement.setNull(index, Types.NULL); } else { ObjectMapper mapper = new ObjectMapper(); try { String json = mapper.writeValueAsString(value); preparedStatement.setString(index, json); } catch (JsonProcessingException e) { throw new HibernateException( "Could not write an instance of the mapped class to a prepared statement."); } } }
From source file:org.jumpmind.db.platform.h2.H2DdlBuilder.java
public H2DdlBuilder() { super(DatabaseNamesConstants.H2); databaseInfo.setNonPKIdentityColumnsSupported(false); databaseInfo.setIdentityOverrideAllowed(false); databaseInfo.setSystemForeignKeyIndicesAlwaysNonUnique(true); databaseInfo.setNullAsDefaultValueRequired(false); databaseInfo.addNativeTypeMapping(Types.ARRAY, "BINARY", Types.BINARY); databaseInfo.addNativeTypeMapping(Types.DISTINCT, "BINARY", Types.BINARY); databaseInfo.addNativeTypeMapping(Types.NULL, "BINARY", Types.BINARY); databaseInfo.addNativeTypeMapping(Types.REF, "BINARY", Types.BINARY); databaseInfo.addNativeTypeMapping(Types.STRUCT, "BINARY", Types.BINARY); databaseInfo.addNativeTypeMapping(Types.DATALINK, "BINARY", Types.BINARY); databaseInfo.addNativeTypeMapping(Types.BIT, "BOOLEAN", Types.BIT); databaseInfo.addNativeTypeMapping(Types.NUMERIC, "DECIMAL", Types.DECIMAL); databaseInfo.addNativeTypeMapping(Types.BINARY, "BINARY", Types.BINARY); databaseInfo.addNativeTypeMapping(Types.BLOB, "BLOB", Types.BLOB); databaseInfo.addNativeTypeMapping(Types.CLOB, "CLOB", Types.CLOB); databaseInfo.addNativeTypeMapping(Types.LONGVARCHAR, "VARCHAR(" + Integer.MAX_VALUE + ")", Types.VARCHAR); databaseInfo.addNativeTypeMapping(Types.FLOAT, "DOUBLE", Types.DOUBLE); databaseInfo.addNativeTypeMapping(Types.JAVA_OBJECT, "OTHER"); databaseInfo.setDefaultSize(Types.CHAR, Integer.MAX_VALUE); databaseInfo.setDefaultSize(Types.VARCHAR, Integer.MAX_VALUE); databaseInfo.setDefaultSize(Types.BINARY, Integer.MAX_VALUE); databaseInfo.setDefaultSize(Types.VARBINARY, Integer.MAX_VALUE); databaseInfo.setNonBlankCharColumnSpacePadded(false); databaseInfo.setBlankCharColumnSpacePadded(false); databaseInfo.setCharColumnSpaceTrimmed(true); databaseInfo.setEmptyStringNulled(false); databaseInfo.setNullAsDefaultValueRequired(true); }
From source file:org.apache.openjpa.jdbc.schema.Schemas.java
/** * Return the SQL type name for the given {@link Types} constant. *///from w ww . j a v a 2s.c om public static String getJDBCName(int type) { switch (type) { case Types.ARRAY: return "array"; case Types.BIGINT: return "bigint"; case Types.BINARY: return "binary"; case Types.BIT: return "bit"; case Types.BLOB: return "blob"; case Types.CHAR: return "char"; case Types.CLOB: return "clob"; case Types.DATE: return "date"; case Types.DECIMAL: return "decimal"; case Types.DISTINCT: return "distinct"; case Types.DOUBLE: return "double"; case Types.FLOAT: return "float"; case Types.INTEGER: return "integer"; case Types.JAVA_OBJECT: return "java_object"; case Types.LONGVARBINARY: return "longvarbinary"; case Types.LONGVARCHAR: return "longvarchar"; case Types.NULL: return "null"; case Types.NUMERIC: return "numeric"; case Types.OTHER: return "other"; case Types.REAL: return "real"; case Types.REF: return "ref"; case Types.SMALLINT: return "smallint"; case Types.STRUCT: return "struct"; case Types.TIME: return "time"; case Types.TIMESTAMP: return "timestamp"; case Types.TINYINT: return "tinyint"; case Types.VARBINARY: return "varbinary"; case Types.VARCHAR: return "varchar"; default: return "unknown(" + type + ")"; } }
From source file:com.yahoo.elide.datastores.hibernate5.usertypes.JsonType.java
/** * {@inheritDoc}/*from w ww .j a va2s. c o m*/ */ @Override public void nullSafeSet(PreparedStatement preparedStatement, Object value, int index, SessionImplementor session) throws HibernateException, SQLException { if (value == null) { preparedStatement.setNull(index, Types.NULL); } else { ObjectMapper mapper = new ObjectMapper(); try { String json = mapper.writeValueAsString(value); preparedStatement.setString(index, json); } catch (JsonProcessingException e) { throw new HibernateException( "Could not write an instance of the mapped class to a prepared statement."); } } }
From source file:net.sf.jdbcwrappers.nulltype.NullTypeTest.java
@Test(expected = SQLException.class) public void crossCheckDerbyBehaviour() throws SQLException { Connection rawConnection = rawDataSource.getConnection(); try {/*from ww w .ja v a 2s. co m*/ PreparedStatement statement = rawConnection.prepareStatement("UPDATE TEST SET CHAR_COL=?"); try { statement.setNull(1, Types.NULL); statement.executeUpdate(); } finally { statement.close(); } } finally { rawConnection.close(); } }
From source file:kr.co.bitnine.octopus.testutils.MemoryDatabaseTest.java
private void verifyTableEquals(JSONObject expectedTable, ResultSet actualRows) throws Exception { ResultSetMetaData actualRowsMetaData = actualRows.getMetaData(); JSONArray expectedSchema = (JSONArray) expectedTable.get("table-schema"); assertEquals(expectedSchema.size(), actualRowsMetaData.getColumnCount()); for (int i = 0; i < expectedSchema.size(); i++) assertEquals(expectedSchema.get(i), actualRowsMetaData.getColumnName(i + 1)); for (Object rowObj : (JSONArray) expectedTable.get("table-rows")) { JSONArray row = (JSONArray) rowObj; actualRows.next();// w w w .j a v a2s . co m for (int i = 0; i < row.size(); i++) { Object expected = row.get(i); Object actual; int sqlType = actualRowsMetaData.getColumnType(i + 1); switch (sqlType) { case Types.INTEGER: if (expected instanceof Boolean) expected = (long) ((Boolean) expected ? 1 : 0); actual = actualRows.getLong(i + 1); break; case Types.NULL: case Types.FLOAT: case Types.VARCHAR: actual = actualRows.getObject(i + 1); break; default: throw new RuntimeException("java.sql.Types " + sqlType + " is not supported"); } assertEquals(expected, actual); } } assertFalse(actualRows.next()); }
From source file:net.sf.jdbcwrappers.nulltype.NullTypeTest.java
@Test public void testSetNull() throws SQLException { Connection connection = dataSource.getConnection(); try {/*from w w w. j a va 2 s .c om*/ PreparedStatement statement = connection.prepareStatement("UPDATE TEST SET CHAR_COL=?"); try { statement.setNull(1, Types.NULL); statement.executeUpdate(); } finally { statement.close(); } } finally { connection.close(); } }