List of usage examples for java.sql PreparedStatement setLong
void setLong(int parameterIndex, long x) throws SQLException;
long
value. From source file:mvc.dao.TarefaDAO.java
public boolean finalizarTarefa(Long id) { String sql = " update tarefas set finalizado=true, " + " dataFinalizacao=now() where id = ? "; try {/*from www . ja va 2 s .c o m*/ PreparedStatement stmt = connection.prepareStatement(sql); stmt.setLong(1, id); stmt.execute(); } catch (SQLException e) { throw new RuntimeException(e); } return true; }
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/*from ww w . jav a 2 s .c om*/ ps.setLong(idx, value); }
From source file:com.softberries.klerk.dao.AddressDao.java
public void delete(Long id, Connection conn) throws SQLException { PreparedStatement st = conn.prepareStatement(SQL_DELETE_ADDRESS); st.setLong(1, id); // run the query int i = st.executeUpdate(); System.out.println("i: " + i); if (i == -1) { System.out.println("db error : " + SQL_DELETE_ADDRESS); }// ww w .jav a 2 s .c o m }
From source file:com.pactera.edg.am.metamanager.extractor.dao.helper.ModifyHarvestMetadataHelper.java
protected void setPs(PreparedStatement ps, MMMetadata metadata, int index) throws SQLException { // START_TIME: ?start_time ps.setLong(7, metadata.getStartTime()); // ID/*from ww w.j a v a2 s. c o m*/ ps.setString(index + 1, taskInstanceId); // ps.setString(index + 2, "0"); // ?:,, ps.setString(index + 3, operType); }
From source file:de.nim.wscr.dao.MemberDAO.java
@Override public void deleteMember(Member member) { try {//from w ww . j a v a 2 s. co m PreparedStatement statement = connection.prepareStatement("DELETE FROM db1.member WHERE ID = ?"); statement.setLong(1, member.getId()); statement.execute(); } catch (SQLException e) { throw new RuntimeException(e); } }
From source file:annis.administration.BinaryImportHelper.java
@Override public Boolean doInPreparedStatement(PreparedStatement ps) throws SQLException, DataAccessException { ps.setString(1, fileDestination.getName()); ps.setLong(2, this.corpusRef); ps.setString(3, this.mimeType); ps.setString(4, fileSource.getName()); ps.executeUpdate();/*www.j ava2s . c o m*/ try { FileUtils.copyFile(fileSource, fileDestination); } catch (IOException ex) { log.error("Could not copy file " + fileSource.getPath(), ex); return false; } return true; }
From source file:com.softberries.klerk.dao.DocumentItemDao.java
public void delete(Long id, Connection conn) throws SQLException { PreparedStatement st = conn.prepareStatement(SQL_DELETE_DOCUMENTITEM); st.setLong(1, id); // run the query int i = st.executeUpdate(); System.out.println("i: " + i); if (i == -1) { System.out.println("db error : " + SQL_DELETE_DOCUMENTITEM); }//w w w. j a v a2 s. c om }
From source file:dao.DiaryPhotoAddQuery.java
/** * This method is used to add blobstreams for a user. <code>Userpage</code> * @param blob - the blob stream//from ww w .j av a2s. com * @param category - the blob type (1 - photos, 2-music, 3-video 4 - documents, 5 - archives) * @param mimeType - the mime type (image/jpeg, application/octet-stream) * @param btitle - the title for this blob * @param bsize - the size of the blob * @param zoom - the zoom for the blob (used for displaying for image/jpeg) * @param caption - caption * @throws Dao Exception - when an error or exception occurs while inserting this blob in DB. * **/ public void addBlob(byte[] blob, int category, String mimeType, String btitle, long bsize, int zoom, String caption) throws BaseDaoException { long dt = System.currentTimeMillis(); Connection conn = null; String stmt = "insert into diaryphotos values(?, ?, ?, ?, ?, ?, ?, ?)"; PreparedStatement s = null; try { conn = dataSource.getConnection(); s = conn.prepareStatement(stmt); s.setLong(1, 0); s.setBytes(2, blob); s.setInt(3, new Integer(category)); s.setString(4, mimeType); s.setString(5, btitle); s.setLong(6, bsize); s.setInt(7, new Integer(zoom)); s.setString(8, caption); s.executeUpdate(); } catch (SQLException e) { logger.error("Error adding a blob in diaryphotos ", e); } finally { if (conn != null) { try { conn.close(); } catch (Exception e) { throw new BaseDaoException("Could not close connection " + stmt, e); } } } }
From source file:net.mindengine.oculus.frontend.service.report.filter.JdbcFilterDAO.java
@Override public long createFilter(Filter filter) throws Exception { String sql = "insert into filters (name, description, user_id, date, filter) values (?,?,?,?,?)"; PreparedStatement ps = getConnection().prepareStatement(sql); ps.setString(1, filter.getName());//from w w w . j av a2 s . c o m ps.setString(2, filter.getDescription()); ps.setLong(3, filter.getUserId()); ps.setTimestamp(4, new Timestamp(filter.getDate().getTime())); ps.setString(5, filter.getFilter()); logger.info(ps); ps.execute(); ResultSet rs = ps.getGeneratedKeys(); if (rs.next()) { return rs.getLong(1); } return 0; }
From source file:com.keybox.manage.db.PublicKeyDB.java
/** * inserts new public key//from w ww.j a v a 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); }