List of usage examples for java.sql CallableStatement execute
boolean execute() throws SQLException;
PreparedStatement
object, which may be any kind of SQL statement. From source file:com.bstek.dorado.core.store.SqlBaseStoreSupport.java
protected void runInitScriptFile(Connection conn, Resource initScriptFile) throws Exception { InputStream is = initScriptFile.getInputStream(); try {/*w w w . java2 s . co m*/ InputStreamReader isr = new InputStreamReader(is, StringUtils.defaultIfEmpty(scriptFileCharset, Constants.DEFAULT_CHARSET)); BufferedReader br = new BufferedReader(isr); StringBuffer scripts = new StringBuffer(); String line = br.readLine(); while (line != null) { scripts.append(line).append('\n'); line = br.readLine(); } if (scripts.length() > 0) { CallableStatement prepareCall = conn.prepareCall(scripts.toString()); try { prepareCall.execute(); } finally { prepareCall.close(); } } br.close(); isr.close(); } finally { is.close(); } }
From source file:com.mobilewallet.common.dao.FeedBackDAO.java
public void feedBack(long userId, String feedType, String feedText, String ip, String email) { Connection connection = null; CallableStatement cstmt = null; try {//from w w w.ja v a 2 s. com connection = dataSource.getConnection(); cstmt = connection.prepareCall("{call FEEDBACK_PROC(?,?,?,?,?)}"); cstmt.setLong(1, userId); cstmt.setString(2, feedType); cstmt.setString(3, feedText); cstmt.setString(4, email); cstmt.setString(5, ip); cstmt.execute(); } catch (Exception ex) { ex.printStackTrace(); } finally { try { if (cstmt != null) { cstmt.close(); } } catch (Exception ex) { } try { if (connection != null) { connection.close(); } } catch (Exception ex) { } } }
From source file:cn.gov.scciq.timer.acceptOrder.FRMDao.java
/** * ????//from w ww. j av a 2 s .c o m * @param exchangeDto */ public static void saveDeclProductFromEnt(CEMSDeclExchangeDto exchangeDto) { Connection conn = null; CallableStatement proc = null; String call = "{call Pro_SaveDeclProductFromEnt(?,?,?,?,?,?,?,?,?)}"; try { conn = DBPool.ds.getConnection(); proc = conn.prepareCall(call); proc.setString(1, exchangeDto.getSEQ_NUM()); proc.setString(2, exchangeDto.getDECL_NO_TYPE()); proc.setString(3, exchangeDto.getDECL_NO()); proc.setString(4, exchangeDto.getRESULT_CONTENT()); proc.setString(5, exchangeDto.getUPDATE_COUNT()); proc.setString(6, exchangeDto.getLAST_OPER_DATE()); proc.setString(7, exchangeDto.getGEN_FLAG()); proc.setString(8, exchangeDto.getTRUE_DECL_NO()); proc.setString(9, exchangeDto.getPROD_NO()); proc.execute(); } catch (SQLException e) { // TODO Auto-generated catch block log.error("N45", e); } catch (Exception e) { log.error("N46", e); } finally { try { if (proc != null) { proc.close(); } if (conn != null) { conn.close(); } } catch (SQLException e) { // TODO Auto-generated catch block log.error("N47", e); } } }
From source file:com.jfootball.dao.hibernate.PlayerDaoImpl.java
public void careerPlayerJob() { logger.info("Fix CareerPlayer job"); Session session = hibernateTemplate.getSessionFactory().getCurrentSession(); SessionFactoryImpl sessionFactory = (SessionFactoryImpl) session.getSessionFactory(); try {/* w w w . j a v a2 s.co m*/ Connection conn = sessionFactory.getConnectionProvider().getConnection(); CallableStatement cstmt = conn.prepareCall("{ call careerPlayerBatch() }"); cstmt.execute(); } catch (SQLException e) { logger.error(e); } logger.info("Fix CareerPlayer job finished"); }
From source file:com.mobilewallet.common.dao.ReferralIncentiveDAO.java
public String showInvitationStrig(long userId) { Connection connection = null; CallableStatement cstmt = null; String show = null;// w w w . ja v a2 s. c o m try { connection = dataSource.getConnection(); cstmt = connection.prepareCall("{call wp_show_invitation(?,?)}"); cstmt.setLong(1, userId); cstmt.registerOutParameter(2, java.sql.Types.VARCHAR); cstmt.execute(); show = cstmt.getString(2); } catch (Exception ex) { ex.printStackTrace(); } finally { try { if (cstmt != null) { cstmt.close(); } } catch (Exception ex) { } try { if (connection != null) { connection.close(); } } catch (Exception ex) { } } return show; }
From source file:com.mobilewallet.users.dao.PushNotificationsDAO.java
public int updateNotification(long userId, String status, String type) { int updated = 0; Connection connection = null; CallableStatement cstmt = null; try {//from w w w . jav a 2 s . co m connection = dataSource.getConnection(); cstmt = connection.prepareCall("{call UPDATE_PUSH_NOTIFICATIONS(?,?,?,?)}"); cstmt.setLong(1, userId); cstmt.setString(2, status); cstmt.setString(3, type); cstmt.registerOutParameter(4, java.sql.Types.INTEGER); cstmt.execute(); updated = cstmt.getInt(4); } catch (Exception ex) { } finally { try { if (cstmt != null) { cstmt.close(); } } catch (Exception ex) { } try { if (connection != null) { connection.close(); } } catch (Exception ex) { } } return updated; }
From source file:com.mobilewallet.users.dao.NotificationsDAO.java
public int updateNotification(long userId, String status, String type) { int updated = 0; Connection connection = null; CallableStatement cstmt = null; try {//from w ww .j av a2 s . c o m connection = dataSource.getConnection(); cstmt = connection.prepareCall("{call wp_update_push_notification(?,?,?,?)}"); cstmt.setLong(1, userId); cstmt.setString(2, status); cstmt.setString(3, type); cstmt.registerOutParameter(4, java.sql.Types.INTEGER); cstmt.execute(); updated = cstmt.getInt(4); } catch (Exception ex) { } finally { try { if (cstmt != null) { cstmt.close(); } } catch (Exception ex) { } try { if (connection != null) { connection.close(); } } catch (Exception ex) { } } return updated; }
From source file:com.nortal.petit.core.dialect.OracleSqlDialect.java
@SuppressWarnings("unchecked") @Override/*from w w w . j a v a 2s. com*/ public <B> B insertReturningId(JdbcOperations jdbcOperations, String sql, String idColumn, final Object... params) { final String actualSql = new StringBuilder("BEGIN ").append(sql) .append(" RETURNING " + idColumn + " INTO ?; END;").toString(); try { return (B) jdbcOperations.execute(new CallableStatementCreator() { @Override public CallableStatement createCallableStatement(Connection con) throws SQLException { CallableStatement cs = con.prepareCall(actualSql); ArgPreparedStatementSetter.setValues(cs, params, 1); cs.registerOutParameter(params.length + 1, Types.DECIMAL); return cs; } }, new CallableStatementCallback<B>() { @Override public B doInCallableStatement(CallableStatement cs) throws SQLException, DataAccessException { cs.execute(); BigDecimal bd = cs.getBigDecimal(params.length + 1); return (B) Long.valueOf(bd.longValue()); } }); } catch (RuntimeException e) { LOG.error("Error processing SQL '" + sql + "' with parameters: " + StringUtils.join(params, "; ")); throw e; } }
From source file:com.mobilewallet.common.dao.LoginDAO.java
public String getUserPassword(String email, String ip) { Connection connection = null; CallableStatement cstmt = null; String password = null;/*from w ww .ja v a2 s. c om*/ try { connection = dataSource.getConnection(); cstmt = connection.prepareCall("{call fp_forgot_password(?,?,?)}"); cstmt.setString(1, email); cstmt.setString(2, ip); cstmt.registerOutParameter(3, java.sql.Types.VARCHAR); cstmt.execute(); password = cstmt.getString(3); } catch (Exception ex) { ex.printStackTrace(); } finally { try { if (cstmt != null) { cstmt.close(); } } catch (Exception ex) { } try { if (connection != null) { connection.close(); } } catch (Exception ex) { } } return password; }
From source file:com.mobilewallet.common.dao.ForgotPasswordDAO.java
public int checkResetLink(String uuid, String userId, String ip) { Connection connection = null; CallableStatement cstmt = null; int rvalue = -1; try {//from w w w. j a v a2 s . co m connection = dataSource.getConnection(); cstmt = connection.prepareCall("{call wp_check_reset_link(?,?,?,?)}"); cstmt.setString(1, userId); cstmt.setString(2, uuid); cstmt.setString(3, ip); cstmt.registerOutParameter(4, java.sql.Types.INTEGER); cstmt.execute(); rvalue = cstmt.getInt(4); log.info("Rvalue Check ResetLink : " + rvalue); } catch (Exception ex) { ex.printStackTrace(); } finally { try { if (cstmt != null) { cstmt.close(); } } catch (Exception ex) { } try { if (connection != null) { connection.close(); } } catch (Exception ex) { } } return rvalue; }