List of usage examples for java.sql PreparedStatement setBytes
void setBytes(int parameterIndex, byte x[]) throws SQLException;
From source file:dao.CarryonTagsUpdateQuery.java
/** * This method is not called by spring.//from www . j a v a2 s . co m * * @param conn the connection is passed to this method * @param btitle the title of the blob * @param zoom the zoom for the images * @param entryid */ public void run(Connection conn, String title, String entryid, String loginid, String usertags) throws BaseDaoException { byte[] caption = { ' ' }; if (!RegexStrUtil.isNull(title)) { caption = title.getBytes(); } /** * Zoom is not applicable to files. Don't update zoom for file blobs **/ try { PreparedStatement stmt = conn.prepareStatement("update carryontag set title=?, usertags='" + usertags + "' where entryid=" + entryid + " and ownerid=" + loginid + ""); stmt.setBytes(1, caption); stmt.executeUpdate(); } catch (Exception e) { throw new BaseDaoException("Error occured while executing update carryontag ", e); } }
From source file:dao.UserAddCobrandQuery.java
/** * This method is not called by spring./* w ww .java 2 s . c om*/ * * @param conn the connection passed to this. * @param loginid the loginid * @param header the header * @param footer the footer * @exception BaseDaoException */ public void run(Connection conn, String loginid, byte[] header, byte[] footer) throws BaseDaoException { PreparedStatement query = null; String stmt = null; try { stmt = "insert into usercobrand values(" + loginid + ", ?, ?)"; query = conn.prepareStatement(stmt); query.setBytes(1, header); query.setBytes(2, footer); query.executeUpdate(); } catch (Exception e) { throw new BaseDaoException("Error occured while executing usercobrand inserting query, query = " + stmt, e); } }
From source file:com.uit.anonymousidentity.Repository.Nonces.NonceJDBCTemplate.java
@Override public boolean isFresh(Nonce n) throws SQLException { String sql = "select * from " + TABLE_NAME + " where " + SID + " = ? and " + VALUE + " = ?"; PreparedStatement pst = dataSource.getConnection().prepareStatement(sql); pst.setString(1, n.getIssuerSid());/*from ww w .j a v a2 s . c om*/ pst.setBytes(2, n.getByteArray()); ResultSet rs = pst.executeQuery(); if (rs.next()) { return false; } else return true; }
From source file:dao.DiaryPhotoAddQuery.java
/** * This method is used to add blobstreams for a user. <code>Userpage</code> * @param blob - the blob stream// w ww. ja v a2s . c o m * @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:dao.DirAddCobrandQuery.java
/** * This method is not called by spring./* w w w. j a va2s .c o m*/ * * @param conn the connection passed to this. * @param directoryid the directoryid * @param header the header * @param footer the footer * @exception BaseDaoException */ public void run(Connection conn, String directoryid, byte[] header, byte[] footer) throws BaseDaoException { PreparedStatement query = null; String stmt = null; try { stmt = "insert into dircobrand values(" + directoryid + ", ?, ?)"; query = conn.prepareStatement(stmt); query.setBytes(1, header); query.setBytes(2, footer); query.executeUpdate(); } catch (Exception e) { throw new BaseDaoException("Error occured while executing dircobrand inserting query, query = " + stmt, e); } }
From source file:dao.CollabrumAddCobrandQuery.java
/** * This method is not called by spring.//from w ww. jav a 2 s.co m * * @param conn the connection passed to this. * @param collabrumid the collabrumid * @param header the header * @param footer the footer * @exception BaseDaoException */ public void run(Connection conn, String collabrumid, byte[] header, byte[] footer) throws BaseDaoException { PreparedStatement query = null; String stmt = null; try { stmt = "insert into collcobrand values(" + collabrumid + ", ?, ?)"; query = conn.prepareStatement(stmt); query.setBytes(1, header); query.setBytes(2, footer); query.executeUpdate(); } catch (Exception e) { throw new BaseDaoException("Error occured while executing collcobrand inserting query, query = " + stmt, e); } }
From source file:dao.CobrandSiteUpdateFooterQuery.java
/** * This method is not called by spring./*from w w w . j a v a 2s.co m*/ * * @param conn the connection passed to this. * @param vhostid the vhostid * @param footer the footer * @exception BaseDaoException */ public void run(Connection conn, String vhostid, byte[] footer) throws BaseDaoException { PreparedStatement query = null; String stmt = null; try { stmt = "update vhosts set footer=? where entryid=" + vhostid + " limit 1"; query = conn.prepareStatement(stmt); query.setBytes(1, footer); query.executeUpdate(); } catch (Exception e) { throw new BaseDaoException("Error occured while executing vhosts updating query, query = " + stmt, e); } }
From source file:dao.CobrandSiteUpdateHeaderQuery.java
/** * This method is not called by spring./*from www . j a v a 2 s.com*/ * * @param conn the connection passed to this. * @param vhostid the vhostid * @param header the header * @exception BaseDaoException */ public void run(Connection conn, String vhostid, byte[] header) throws BaseDaoException { PreparedStatement query = null; String stmt = null; try { stmt = "update vhosts set header=? where entryid=" + vhostid + " limit 1"; query = conn.prepareStatement(stmt); query.setBytes(1, header); query.executeUpdate(); } catch (Exception e) { throw new BaseDaoException( "Error occured while executing cobrandsiteupdatingheader query, query = " + stmt, e); } }
From source file:dao.UserCobrandUpdateFooterQuery.java
/** * This method is not called by spring./* w w w .j ava 2s . c o m*/ * * @param conn the connection passed to this. * @param loginid the loginid * @param footer the footer * @exception BaseDaoException */ public void run(Connection conn, String loginid, byte[] footer) throws BaseDaoException { PreparedStatement query = null; String stmt = null; try { stmt = "update usercobrand set footer=? where loginid=" + loginid + " limit 1"; query = conn.prepareStatement(stmt); query.setBytes(1, footer); query.executeUpdate(); } catch (Exception e) { throw new BaseDaoException("Error occured while executing usercobrand updating query, query = " + stmt, e); } }
From source file:dao.UserCobrandUpdateHeaderQuery.java
/** * This method is not called by spring.//w ww . j av a2 s . co m * * @param conn the connection passed to this. * @param loginid the loginid * @param header the header * @exception BaseDaoException */ public void run(Connection conn, String loginid, byte[] header) throws BaseDaoException { PreparedStatement query = null; String stmt = null; try { stmt = "update usercobrand set header=? where loginid=" + loginid + " limit 1"; query = conn.prepareStatement(stmt); query.setBytes(1, header); query.executeUpdate(); } catch (Exception e) { throw new BaseDaoException("Error occured while executing usercobrand updating query, query = " + stmt, e); } }