List of usage examples for java.sql PreparedStatement executeUpdate
int executeUpdate() throws SQLException;
PreparedStatement
object, which must be an SQL Data Manipulation Language (DML) statement, such as INSERT
, UPDATE
or DELETE
; or an SQL statement that returns nothing, such as a DDL statement. From source file:dao.CollMembersAddQuery.java
/** * This method adds collabrum member to a given collabrum * @param conn - the connection/*from ww w . ja v a2 s . c o m*/ * @param collabrumId - the collabrumid * @param myownerid - the owner id * @throws BaseDaoException - when an error occurs **/ public void run(Connection conn, String collabrumid, String myownerid) throws BaseDaoException { try { String query = "insert into collmembers values(" + collabrumid + ", " + myownerid + ")"; logger.info("query = " + query); PreparedStatement stmt = conn.prepareStatement(query); stmt.executeUpdate(); } catch (Exception e) { logger.warn("Error occured while executing collmembers addquery", e); throw new BaseDaoException("Error occured while executing collmembers addquery", e); } }
From source file:dao.PblogTagUpdateQuery.java
/** * This method is not called by spring./*ww w . jav a 2s. c o 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 tid, String ownerid, String usertags) throws BaseDaoException { String query = "update pblogtags set usertags='" + usertags + "' where ownerid=" + ownerid + " and tid=" + tid + ""; try { // PreparedStatement stmt = conn.prepareStatement("update pblogtags set usertags='"+usertags+"' where ownerid="+ownerid+" and tid="+tid+""); PreparedStatement stmt = conn.prepareStatement(query); stmt.executeUpdate(); } catch (Exception e) { throw new BaseDaoException("Error in PblogTagUpdateQuery " + query, e); } }
From source file:dao.PblogTagWordsUpdateQuery.java
/** * This method is not called by spring./*www . j av a 2 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 tid, String ownerid, String newusertags) throws BaseDaoException { String query = "update low_priority pblogtags set usertags=CONCAT(usertags,',','" + newusertags + "') where ownerid=1"; try { //PreparedStatement stmt = conn.prepareStatement("update pblogtags set usertags=CONCAT'"+usertags+"' where ownerid="+ownerid+" and tid="+tid+""); PreparedStatement stmt = conn.prepareStatement(query); stmt.executeUpdate(); } catch (Exception e) { throw new BaseDaoException("Error PblogTagWordsUpdateQuery " + query, e); } }
From source file:dao.CarryonUpdateCaptionQuery.java
/** * This method is not called by spring.// w ww . j av a 2 s. c om * * @param conn the connection is passed to this method * @param entryid * @param loginid * @param caption */ public void run(Connection conn, String entryid, String loginid, String caption) throws BaseDaoException { String query = "update carryon set caption='" + caption + "' where entryid=" + entryid + " and loginid=" + loginid + ""; try { //PreparedStatement stmt = conn.prepareStatement("update carryon set caption='"+caption+"' where entryid="+entryid+" and loginid="+loginid+""); PreparedStatement stmt = conn.prepareStatement(query); stmt.executeUpdate(); } catch (Exception e) { logger.warn("Error occured while executing only caption CarryonUpdateCaptionQuery, query=" + query, e); throw new BaseDaoException("Error occured while executing update caption, carryon ", e); } }
From source file:dao.DeActivateUsertabAccountQuery.java
/** * Method adds a user to diarynet/*ww w .j a v a2 s .c o m*/ * @param conn - the connection * @param params * informpm - * informbb - * informfd - * loginid * @throws BaseDaoException - when error occurs **/ public void run(Connection conn, String[] params) throws BaseDaoException { String loginid = params[0]; try { String query = ("update hdprofile set informpm=0, informbb=0, informfd=0 where loginid=" + loginid + ""); logger.info("DeActivateUsertabAccountQuery = " + query); PreparedStatement stmt = conn.prepareStatement(query); stmt.executeUpdate(); } catch (Exception e) { logger.warn("Error occured while executing DeActivateUsertabAccountQuery", e); throw new BaseDaoException("Error occured while executing DeActivateUsertabAccountQuery", e); } }
From source file:dao.PblogMsgAddAttributeQuery.java
/** * This method is not called by spring.//from ww w .j a v a 2s . c o m * This method is used to add collabrum message attributes * @param conn the connection passed to this. * @param tid the thread id * @param rid the reply thread id * @param fontSize the font size * @param fontFace the font face * @param fontColor the font color * @param moodid the mood id * @param bgColor the bg color * @exception BaseDaoException */ public void run(Connection conn, String tid, String rid, String fontSize, String fontFace, String fontColor, String moodid, String bgColor, String loginid) throws BaseDaoException { String stmt = null; try { stmt = "insert into pblogmsgattr values (" + loginid + ", " + tid + ", " + rid + ", " + fontSize + ", '" + fontFace + "', '" + fontColor + "', " + moodid + ", '" + bgColor + "')"; PreparedStatement query = conn.prepareStatement(stmt); query.executeUpdate(); } catch (Exception e) { throw new BaseDaoException("Error inserting pblogmsgattr " + stmt, e); } }
From source file:dao.VisitTrafficAddQuery.java
/** * Method adds a user to diarynet/*w w w . j a va2 s . c om*/ * @param conn - the connection * @param params * @throws BaseDaoException - when error occurs **/ public void run(Connection conn, String[] params) throws BaseDaoException { String login = params[0]; String ipaddress = params[1]; String referer = params[2]; String url = params[3]; String method = params[4]; String host = params[5]; String query = "insert into visittraffic values (0, '" + login + "', '" + ipaddress + "', '" + referer + "', '" + url + "', '" + method + "', '" + host + "', CURRENT_TIMESTAMP())"; try { //PreparedStatement stmt = conn.prepareStatement("insert into visittraffic values (0, '"+login+"', '"+ipaddress+"', '"+referer+"', '"+url+"', '"+method+"', '"+host+"', CURRENT_TIMESTAMP())"); PreparedStatement stmt = conn.prepareStatement(query); stmt.executeUpdate(); } catch (Exception e) { logger.warn("Error executing VisitTrafficAddQuery, " + query, e); throw new BaseDaoException("Error executing VisitTrafficAddQuery" + query, e); } }
From source file:com.wso2telco.dbUtil.DataBaseConnectUtils.java
/** * Update user details in Back Channeling Scenario : update oauth code * * @param correlationId unique ID of the request * @param token access token//from www. j a v a 2s .c o m */ public static void updateTokenInBackChannel(String correlationId, String token) throws ConfigurationException, CommonAuthenticatorException { Connection connection = null; PreparedStatement preparedStatement = null; String updateUserDetailsQuery = "update backchannel_request_details set access_token=? where correlation_id=?"; try { connection = getConnectDBConnection(); if (log.isDebugEnabled()) { log.debug("Executing the query " + updateUserDetailsQuery); } preparedStatement = connection.prepareStatement(updateUserDetailsQuery); preparedStatement.setString(1, token); preparedStatement.setString(2, correlationId); preparedStatement.executeUpdate(); } catch (SQLException e) { handleException("Error occurred while updating user details for : " + correlationId + "in " + "BackChannel Scenario.", e); } catch (NamingException e) { throw new ConfigurationException("DataSource could not be found in mobile-connect.xml"); } finally { closeAllConnections(preparedStatement, connection); } }
From source file:com.cisco.iwe.services.util.EmailMonitor.java
/** This method saves the email contents in the database **/ public static void saveAttachmentAndText(String from, String subject, byte[] mailAttachment, byte[] MailText, String fileType, Date sent, String pdfText) throws Exception { Connection conn = null;//from ww w.j a v a2 s. c om PreparedStatement stmt = null; try { String query = EmailParseConstants.saveQuery; conn = DataBaseUtil.getDevConnection(); // DataBaseUtil.getConnection(jndiName+"_"+System.getProperty("cisco.life")); conn.setAutoCommit(false); stmt = conn.prepareStatement(query); stmt.setString(1, from); stmt.setString(2, subject); stmt.setBinaryStream(3, new ByteArrayInputStream(mailAttachment), mailAttachment.length); stmt.setBinaryStream(4, new ByteArrayInputStream(MailText), MailText.length); stmt.setString(5, fileType); stmt.setTimestamp(6, new Timestamp(sent.getTime())); stmt.executeUpdate(); } finally { try { if (stmt != null) { } } finally { if (conn != null) { conn.close(); } } } }
From source file:dao.PblogDeleteRecentVisitQuery.java
/** * This method is executed by PblogMessageDao * This method deletes row(s) on low_priority basis from pblogrecentvisits table * @param conn - the connection//w w w . ja v a2 s.c om * @throws BaseDaoException **/ public void run(Connection conn, int numRows) throws BaseDaoException { String stmt = "delete low_priority from pblogrecentvisits ORDER BY entrydate limit " + numRows + ""; try { PreparedStatement query = null; query = conn.prepareStatement(stmt); query.executeUpdate(); } catch (Exception e) { throw new BaseDaoException("Error occured while executing pblogtopics addquery, stmt = " + stmt, e); } }