List of usage examples for java.sql Connection prepareCall
CallableStatement prepareCall(String sql) throws SQLException;
CallableStatement
object for calling database stored procedures. From source file:com.nortal.petit.core.dialect.OracleSqlDialect.java
@SuppressWarnings("unchecked") @Override// w w w. j ava2 s. c o m 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.persistent.cloudninja.dao.impl.KpiValueTempDaoImpl.java
@Override public void executeProcessKpiValues() { try {/*from www . j a v a 2s .c o m*/ jdbcTemplate.call(new CallableStatementCreator() { @Override public CallableStatement createCallableStatement(Connection con) throws SQLException { CallableStatement cs = con.prepareCall("{ call ProcessKpiValues() }"); return cs; } }, new ArrayList<SqlParameter>()); } catch (Exception e) { LOGGER.error(e.getMessage(), e); } }
From source file:cn.gov.scciq.timer.acceptOrder.FRMDao.java
/** * ?CIQ?/*from w w w. ja va 2 s . c om*/ * --?0??0 */ public static int saveCIQDeclInfo(CEMSDeclDataDto declDto) { int retCode = -1; Connection conn = null; CallableStatement proc = null; String call = "{call Pro_SaveCIQDeclInfo(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}"; try { conn = DBPool.ds.getConnection(); proc = conn.prepareCall(call); proc.setString(1, declDto.getDecl_No()); proc.setString(2, declDto.getDecl_Get_No()); proc.setString(3, declDto.getDecl_Reg_No()); proc.setString(4, declDto.getDecl_Person_Code()); proc.setString(5, declDto.getDecl_Date()); proc.setString(6, declDto.getEnt_Property()); proc.setString(7, declDto.getConsignor_Code()); proc.setString(8, declDto.getConsignor_CName()); proc.setString(9, declDto.getConsignor_EName()); proc.setString(10, declDto.getConsignee_Code()); proc.setString(11, declDto.getConsignee_CName()); proc.setString(12, declDto.getConsignee_EName()); proc.setString(13, declDto.getTrans_Type_Code()); proc.setString(14, declDto.getTrans_Means_Code()); proc.setString(15, declDto.getTonnage()); proc.setString(16, declDto.getTrade_Mode_Code()); proc.setString(17, declDto.getGoods_Place_Code()); proc.setString(18, declDto.getGoods_Place()); proc.setString(19, declDto.getPurpose_Code()); proc.setString(20, declDto.getDecl_Date()); proc.setString(21, declDto.getArri_Date()); proc.setString(22, declDto.getUnload_Date()); proc.setString(23, declDto.getDesp_Port_Code()); proc.setString(24, declDto.getArri_Port_Code()); proc.setString(25, declDto.getEntry_Port_Code()); proc.setString(26, declDto.getVia_Port_Code()); proc.setString(27, declDto.getDest_Code()); proc.setString(28, declDto.getTrade_Country_Code()); proc.setString(29, declDto.getDesp_Country_Code()); proc.setString(30, declDto.getSituation_Code()); proc.setString(31, declDto.getSituation_Level()); proc.setString(32, declDto.getCounter_Claim()); proc.setString(33, declDto.getContract_No()); proc.setString(34, declDto.getCarrier_Note_No()); proc.setString(35, declDto.getLicense_Code()); proc.setString(36, declDto.getApprove_Code()); proc.setString(37, declDto.getProd_Reg_No()); proc.setString(38, declDto.getExchange_Note_Codes()); proc.setString(39, declDto.getExchange_Note_Num()); proc.setString(40, declDto.getPack_Cap_Resu_Codes()); proc.setString(41, declDto.getPack_Use_Resu_Codes()); proc.setString(42, declDto.getSheet_Type_Codes()); proc.setString(43, declDto.getCert_Type_Codes()); proc.setString(44, declDto.getCert_Originals()); proc.setString(45, declDto.getCert_Copies()); proc.setString(46, declDto.getSpecial_Require()); proc.setString(47, declDto.getMark_No()); proc.setString(48, declDto.getValue_Checkup_Flag()); proc.setString(49, declDto.getInsp_Mode_Code()); proc.setString(50, declDto.getInsp_Org_Code()); proc.setString(51, declDto.getInsp_Dept_1()); proc.setString(52, declDto.getInsp_Dept_2()); proc.setString(53, declDto.getInsp_Dept_3()); proc.setString(54, declDto.getInsp_Dept_4()); proc.setString(55, declDto.getInsp_Dept_5()); proc.setString(56, declDto.getDecl_Type_Code()); proc.setString(57, declDto.getProcess_Status()); proc.setString(58, declDto.getFee_Status()); proc.setString(59, declDto.getValues_USD()); proc.setString(60, declDto.getValues_RMB()); proc.setString(61, declDto.getOperator_Code()); proc.setString(62, declDto.getOperate_Date()); proc.setString(63, declDto.getStat_Flag()); proc.setString(64, declDto.getWaste_Flag()); proc.setString(65, declDto.getRelease_Status()); proc.setString(66, declDto.getCheckup_Type_Code()); proc.setString(67, declDto.getCheckup_Work_Code()); proc.setString(68, declDto.getOrg_Code()); proc.setString(69, declDto.getDept_Code()); proc.setString(70, declDto.getDest_Org_Code()); proc.setString(71, declDto.getFlow_Flag()); proc.setString(72, declDto.getTrans_Flag()); proc.setString(73, declDto.getInputer_Code()); proc.setString(74, declDto.getInput_Date()); proc.setString(75, declDto.getEnt_Decl_No()); proc.setString(76, declDto.getO_I_Flag()); proc.setString(77, declDto.getChg_Org_Code()); proc.setString(78, declDto.getChg_Person_Code()); proc.setString(79, declDto.getChg_Date()); proc.setString(80, declDto.getCheck_Flag()); proc.setString(81, declDto.getInput_Org_Code()); proc.setString(82, declDto.getDECL_FLAG()); proc.setString(83, declDto.getCUSTOM_CODE()); proc.setString(84, declDto.getAUTO_PASS_FLAG()); proc.setString(85, declDto.getAUTO_CHECK_FLAG()); proc.setString(86, declDto.getBACK_TRANSPORT_FLAG()); proc.setString(87, declDto.getCONTACTOR()); proc.setString(88, declDto.getTELEPHONE()); proc.setString(89, declDto.getPROCESS_FLAG()); proc.setString(90, declDto.getMONITOR_PASS_FLAG()); proc.setString(91, declDto.getCOMPUTE_PASS_FLAG()); proc.setString(92, declDto.getTRANS_MEANS_NAME()); proc.setString(93, declDto.getMONITOR_FLAG()); proc.setString(94, declDto.getSPOTTEST_FLAG()); proc.setString(95, declDto.getCOMB_BATCH_NO()); proc.setString(96, declDto.getRESEND_NUM()); proc.setString(97, declDto.getCHANGE_INSP_DEPT_FLAG()); proc.setString(98, declDto.getCIQ2000_ASSIGN_FLAG()); proc.setString(99, declDto.getMonitor_Decl_Flag()); proc.setString(100, declDto.getSEQ_NUM()); proc.registerOutParameter(101, Types.INTEGER); proc.execute(); retCode = proc.getInt(101); } catch (SQLException e) { // TODO Auto-generated catch block log.error("num9", e); } catch (Exception e) { log.error("num10", e); } finally { try { if (proc != null) { proc.close(); } if (conn != null) { conn.close(); } } catch (SQLException e) { // TODO Auto-generated catch block log.error("num11", e); } } return retCode; }
From source file:com.mmnaseri.dragonfly.statement.impl.ProcedureCallStatement.java
@Override public PreparedStatement prepare(Connection connection) { try {//from w w w .j a v a 2 s . c o m log.info("Preparing statement: " + getSql()); return connection.prepareCall(getSql()); } catch (SQLException e) { throw new StatementPreparationError("Failed to prepare statement through connection", e); } }
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 {/* ww w .j a v a 2 s . c o m*/ 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:com.mobilewallet.common.dao.RegisterDAO.java
public void updateGCM(String userId, String gcmId) { Connection con = null; CallableStatement cstmt = null; try {/*from www .jav a 2 s. c o m*/ con = ds.getConnection(); cstmt = con.prepareCall("{call wp_update_gcm(?,?,?)}"); cstmt.setString(1, userId); cstmt.setString(2, gcmId); cstmt.registerOutParameter(3, java.sql.Types.VARCHAR); cstmt.execute(); } catch (Exception ex) { } finally { try { if (cstmt != null) { cstmt.close(); } } catch (Exception ex) { } try { if (con != null) { con.close(); } } catch (Exception ex) { } } }
From source file:com.bstek.dorado.core.store.H2BaseStore.java
protected void prepareNamespace() throws Exception { Class.forName(driverClassName); Connection conn = DriverManager.getConnection(getConnectionUrl(), username, password); try {//from w w w .j a v a 2 s . c om int storeVersion = 0; CallableStatement prepareCall = conn.prepareCall("SELECT @storeVersion"); ResultSet resultSet = prepareCall.executeQuery(); try { if (resultSet.first()) { storeVersion = resultSet.getInt("@storeVersion"); } } finally { resultSet.close(); prepareCall.close(); } if (storeVersion < version) { logger.info("Initializing store \"" + namespace + "\"."); prepareCall = conn.prepareCall("SET @storeVersion = " + version); try { prepareCall.execute(); } finally { prepareCall.close(); } initNamespace(conn); } } finally { conn.close(); } }
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 {//w w w. ja v a 2s . 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.mobilewallet.users.dao.PushNotificationsDAO.java
public int updateNotification(long userId, String status, String type) { int updated = 0; Connection connection = null; CallableStatement cstmt = null; try {//w ww . j a v a2 s. c o 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.common.dao.RegisterDAO.java
public Object[] registerUser(String email, String fname, String lname, String dob, String gender, String pwd, String imei, String accounts, String country, String handsetModel, String androidVer, String emulator, String gcmId, String androidId, String refCode, String ip, String fbId) { Object[] obj = null;/* w w w. j a v a2s . c o m*/ Connection con = null; CallableStatement cstmt = null; try { con = ds.getConnection(); cstmt = con.prepareCall("{call REGISTER_USER(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}"); cstmt.setString(1, email); cstmt.setString(2, fname); cstmt.setString(3, lname); cstmt.setString(4, dob); cstmt.setString(5, gender); cstmt.setString(6, pwd); cstmt.setString(7, imei); cstmt.setString(8, accounts); cstmt.setString(9, country); cstmt.setString(10, handsetModel); cstmt.setString(11, androidVer); cstmt.setString(12, emulator); cstmt.setString(13, gcmId); cstmt.setString(14, androidId); cstmt.setString(15, refCode); cstmt.setString(16, ip); cstmt.setString(17, fbId); cstmt.registerOutParameter(18, java.sql.Types.INTEGER); cstmt.registerOutParameter(19, java.sql.Types.VARCHAR); cstmt.registerOutParameter(20, java.sql.Types.INTEGER); cstmt.registerOutParameter(21, java.sql.Types.INTEGER); cstmt.execute(); obj = new Object[4]; obj[0] = cstmt.getInt(18);//rvalue obj[1] = cstmt.getString(19);//user ref code obj[2] = cstmt.getFloat(20);//balance obj[3] = cstmt.getLong(21);//user id } catch (Exception ex) { ex.printStackTrace(); } finally { try { if (cstmt != null) { cstmt.close(); } } catch (Exception ex) { } try { if (con != null) { con.close(); } } catch (Exception ex) { } } return obj; }