List of usage examples for java.sql PreparedStatement setNull
void setNull(int parameterIndex, int sqlType) throws SQLException;
NULL
. From source file:com.act.lcms.db.model.ScanFile.java
protected static void bindInsertOrUpdateParameters(PreparedStatement stmt, String filename, SCAN_MODE mode, SCAN_FILE_TYPE fileType, Integer plateId, Integer plateRow, Integer plateColumn) throws SQLException { stmt.setString(DB_FIELD.FILENAME.getInsertUpdateOffset(), filename); stmt.setString(DB_FIELD.MODE.getInsertUpdateOffset(), mode.name()); stmt.setString(DB_FIELD.FILE_TYPE.getInsertUpdateOffset(), fileType.name()); if (plateId != null) { stmt.setInt(DB_FIELD.PLATE_ID.getInsertUpdateOffset(), plateId); } else {/*from w w w .ja v a 2 s. com*/ stmt.setNull(DB_FIELD.PLATE_ID.getInsertUpdateOffset(), Types.INTEGER); } if (plateRow != null) { stmt.setInt(DB_FIELD.PLATE_ROW.getInsertUpdateOffset(), plateRow); } else { stmt.setNull(DB_FIELD.PLATE_ROW.getInsertUpdateOffset(), Types.INTEGER); } if (plateColumn != null) { stmt.setInt(DB_FIELD.PLATE_COLUMN.getInsertUpdateOffset(), plateColumn); } else { stmt.setNull(DB_FIELD.PLATE_COLUMN.getInsertUpdateOffset(), Types.INTEGER); } }
From source file:at.alladin.rmbt.db.fields.StringField.java
@Override public void getField(final PreparedStatement ps, final int idx) throws SQLException { if (value == null) ps.setNull(idx, Types.VARCHAR); else/* w w w .ja v a 2 s . com*/ ps.setString(idx, value); }
From source file:at.alladin.rmbt.db.fields.UUIDField.java
@Override public void getField(final PreparedStatement ps, final int idx) throws SQLException { if (value == null) ps.setNull(idx, Types.OTHER); else// ww w . j a va 2 s. c o m ps.setObject(idx, value); }
From source file:at.alladin.rmbt.db.fields.BooleanField.java
@Override public void getField(final PreparedStatement ps, final int idx) throws SQLException { if (value == null) ps.setNull(idx, Types.BOOLEAN); else/* ww w.j av a 2s . com*/ ps.setBoolean(idx, value); }
From source file:at.alladin.rmbt.db.fields.TimestampField.java
@Override public void getField(final PreparedStatement ps, final int idx) throws SQLException { if (value == null) ps.setNull(idx, Types.TIMESTAMP); else/*from www . j a v a2 s .c om*/ ps.setTimestamp(idx, value); }
From source file:at.alladin.rmbt.db.fields.LongField.java
@Override public void getField(final PreparedStatement ps, final int idx) throws SQLException { if (value == null) ps.setNull(idx, Types.BIGINT); else/*ww w . j a v a2 s . c o m*/ ps.setLong(idx, value); }
From source file:at.alladin.rmbt.db.fields.DoubleField.java
@Override public void getField(final PreparedStatement ps, final int idx) throws SQLException { if (value == null) ps.setNull(idx, Types.DOUBLE); else/*from w w w .ja v a 2s. c om*/ ps.setDouble(idx, value); }
From source file:at.alladin.rmbt.db.fields.IntField.java
@Override public void getField(final PreparedStatement ps, final int idx) throws SQLException { if (value == null) ps.setNull(idx, Types.INTEGER); else/* ww w. j a v a 2 s . com*/ ps.setInt(idx, value); }
From source file:com.keybox.manage.db.PublicKeyDB.java
/** * inserts new public key/*from w w w. j a va 2 s. com*/ * * @param publicKey key object */ public static void insertPublicKey(PublicKey publicKey) { Connection con = null; try { con = DBUtils.getConn(); PreparedStatement stmt = con.prepareStatement( "insert into public_keys(key_nm, type, fingerprint, public_key, profile_id, user_id) values (?,?,?,?,?,?)"); stmt.setString(1, publicKey.getKeyNm()); stmt.setString(2, SSHUtil.getKeyType(publicKey.getPublicKey())); stmt.setString(3, SSHUtil.getFingerprint(publicKey.getPublicKey())); stmt.setString(4, publicKey.getPublicKey().trim()); if (publicKey.getProfile() == null || publicKey.getProfile().getId() == null) { stmt.setNull(5, Types.NULL); } else { stmt.setLong(5, publicKey.getProfile().getId()); } stmt.setLong(6, publicKey.getUserId()); stmt.execute(); DBUtils.closeStmt(stmt); } catch (Exception e) { log.error(e.toString(), e); } DBUtils.closeConn(con); }
From source file:com.keybox.manage.db.PublicKeyDB.java
/** * updates existing public key/*from w ww .jav a2 s . c o m*/ * * @param publicKey key object */ public static void updatePublicKey(PublicKey publicKey) { Connection con = null; try { con = DBUtils.getConn(); PreparedStatement stmt = con.prepareStatement( "update public_keys set key_nm=?, type=?, fingerprint=?, public_key=?, profile_id=? where id=? and user_id=? and enabled=true"); stmt.setString(1, publicKey.getKeyNm()); stmt.setString(2, SSHUtil.getKeyType(publicKey.getPublicKey())); stmt.setString(3, SSHUtil.getFingerprint(publicKey.getPublicKey())); stmt.setString(4, publicKey.getPublicKey().trim()); if (publicKey.getProfile() == null || publicKey.getProfile().getId() == null) { stmt.setNull(5, Types.NULL); } else { stmt.setLong(5, publicKey.getProfile().getId()); } stmt.setLong(6, publicKey.getId()); stmt.setLong(7, publicKey.getUserId()); stmt.execute(); DBUtils.closeStmt(stmt); } catch (Exception e) { log.error(e.toString(), e); } DBUtils.closeConn(con); }