List of usage examples for java.sql ResultSet wasNull
boolean wasNull() throws SQLException;
NULL
. From source file:jp.co.tis.gsp.tools.dba.dialect.SqlserverDialect.java
private boolean existsSchema(Connection conn, String schema) throws SQLException { PreparedStatement stmt = null; try {//from w ww. j a v a 2 s . co m stmt = conn.prepareStatement("SELECT SCHEMA_ID('" + schema + "') as id"); ResultSet rs = stmt.executeQuery(); rs.next(); rs.getInt("id"); return (!rs.wasNull()); } finally { StatementUtil.close(stmt); } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstXMsgClient.CFAstXMsgClientSchema.java
public static String getNullableString(ResultSet reader, int colidx) { try {/*from ww w. j av a 2 s. c om*/ String val = reader.getString(colidx); if (reader.wasNull()) { return (null); } else { return (val); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(CFAstXMsgClientSchema.class, "getNullableString", e); } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstXMsgClient.CFAstXMsgClientSchema.java
public static BigDecimal getNullableUInt64(ResultSet reader, int colidx) { try {//w w w.j av a 2 s .c o m String strval = reader.getString(colidx); if (reader.wasNull() || (strval == null) || (strval.length() <= 0)) { return (null); } else { BigDecimal retval = new BigDecimal(strval); return (retval); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(CFAstXMsgClientSchema.class, "getNullableUInt64", e); } }
From source file:org.intelligentsia.utility.jpa.usertype.JSONUserType.java
public Object nullSafeGet(final ResultSet rs, final String[] names, final Object owner) throws HibernateException, SQLException { try {/*from w ww .ja va2s. co m*/ final String value = rs.getString(names[0]); if (!rs.wasNull()) { if (value != null) { return mapper.readValue(value, exposedClass); } } } catch (final JsonMappingException e) { throw new RuntimeException(e); } catch (final JsonParseException e) { throw new RuntimeException(e); } catch (final IOException e) { throw new RuntimeException(e); } return null; }
From source file:net.solarnetwork.node.dao.jdbc.consumption.test.JdbcConsumptionDatumDaoTest.java
@Test public void storeNew() { ConsumptionDatum datum = new ConsumptionDatum(TEST_SOURCE_ID, TEST_AMPS, TEST_VOLTS); datum.setCreated(new Date()); datum.setWattHourReading(TEST_WATT_HOUR_READING); dao.storeDatum(datum);//from www . j a v a2s. c o m jdbcOps.query(SQL_GET_BY_ID, new Object[] { new java.sql.Timestamp(datum.getCreated().getTime()), TEST_SOURCE_ID }, new ResultSetExtractor<Object>() { @Override public Object extractData(ResultSet rs) throws SQLException, DataAccessException { assertTrue("Must have one result", rs.next()); int col = 1; String s = rs.getString(col++); assertFalse(rs.wasNull()); assertEquals(TEST_SOURCE_ID, s); rs.getTimestamp(col++); assertFalse(rs.wasNull()); Float f = rs.getFloat(col++); assertFalse(rs.wasNull()); assertEquals(TEST_VOLTS.doubleValue(), f.doubleValue(), 0.001); f = rs.getFloat(col++); assertFalse(rs.wasNull()); assertEquals(TEST_AMPS.doubleValue(), f.doubleValue(), 0.001); Long l = rs.getLong(col++); assertFalse(rs.wasNull()); assertEquals(TEST_WATT_HOUR_READING, l); assertFalse("Must not have more than one result", rs.next()); return null; } }); }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccXMsgClient.CFAccXMsgClientSchema.java
public static Integer getNullableInt32(ResultSet reader, int colidx) { try {//from w ww.ja v a 2 s .com int val = reader.getInt(colidx); if (reader.wasNull()) { return (null); } else { return (new Integer(val)); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(CFAccXMsgClientSchema.class, "getNullableInt32", e); } }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccXMsgClient.CFAccXMsgClientSchema.java
public static Integer getNullableUInt16(ResultSet reader, int colidx) { try {/*w w w .ja v a2 s. c o m*/ int val = reader.getInt(colidx); if (reader.wasNull()) { return (null); } else { return (new Integer(val)); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(CFAccXMsgClientSchema.class, "getNullableUInt16", e); } }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccXMsgClient.CFAccXMsgClientSchema.java
public static Long getNullableUInt32(ResultSet reader, int colidx) { try {//w w w. j a v a 2 s. co m long val = reader.getLong(colidx); if (reader.wasNull()) { return (null); } else { return (new Long(val)); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(CFAccXMsgClientSchema.class, "getNullableUInt32", e); } }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccXMsgClient.CFAccXMsgClientSchema.java
public static Byte getNullableByte(ResultSet reader, int colidx) { try {//from w w w . j av a 2 s. co m byte val = reader.getByte(colidx); if (reader.wasNull()) { return (null); } else { return (new Byte(val)); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(CFAccXMsgClientSchema.class, "getNullableByte", e); } }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccXMsgClient.CFAccXMsgClientSchema.java
public static Short getNullableInt16(ResultSet reader, int colidx) { try {/*from w w w. j a va2 s. c om*/ short val = reader.getShort(colidx); if (reader.wasNull()) { return (null); } else { return (new Short(val)); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(CFAccXMsgClientSchema.class, "getNullableInt64", e); } }