List of usage examples for java.sql CallableStatement getInt
int getInt(String parameterName) throws SQLException;
INTEGER
parameter as an int
in the Java programming language. From source file:com.mobilewallet.credits.dao.CreditsDAO.java
public int updateCredits(long userId, String isCorrect, int position) { int updated = 0; Connection connection = null; CallableStatement cstmt = null; try {/* w w w . j a v a 2 s . c om*/ connection = dataSource.getConnection(); cstmt = connection.prepareCall("{call update_credits_proc(?,?,?,?)}"); cstmt.setLong(1, userId); cstmt.setString(2, isCorrect); cstmt.setInt(3, position); cstmt.registerOutParameter(4, java.sql.Types.INTEGER); cstmt.execute(); updated = cstmt.getInt(4); } 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 updated; }
From source file:com.mobilewallet.admin.dao.QuestionDAO.java
public int approveQuestion(long userId, long q_id, String is_admin_approved) { Connection connection = null; CallableStatement pstmt = null; ResultSet rs = null;//from www . java 2s .c om int approved = 0; try { connection = dataSource.getConnection(); pstmt = connection.prepareCall("{call approve_question(?,?,?,?)}"); pstmt.setLong(1, userId); pstmt.setLong(2, q_id); pstmt.setString(3, is_admin_approved); pstmt.registerOutParameter(4, java.sql.Types.INTEGER); pstmt.execute(); approved = pstmt.getInt(4); } catch (Exception ex) { ex.printStackTrace(); } finally { try { if (rs != null) { rs.close(); } } catch (Exception ex) { } try { if (pstmt != null) { pstmt.close(); } } catch (Exception ex) { } try { if (connection != null) { connection.close(); } } catch (Exception ex) { } } return approved; }
From source file:com.mobilewallet.common.dao.ForgotPasswordDAO.java
public Object[] getResetPasswordLink(String email, String uuid, String ip) { Connection connection = null; CallableStatement cstmt = null; Object[] obj = null;/*from ww w . java 2 s.c o m*/ int rvalue = -1; long userId = 0; try { connection = dataSource.getConnection(); cstmt = connection.prepareCall("{call wp_forgot_pwd_reset_link(?,?,?,?,?)}"); cstmt.setString(1, email); cstmt.setString(2, uuid); cstmt.setString(3, ip); cstmt.registerOutParameter(4, java.sql.Types.INTEGER); cstmt.registerOutParameter(5, java.sql.Types.INTEGER); cstmt.execute(); rvalue = cstmt.getInt(4); userId = cstmt.getLong(5); obj = new Object[2]; obj[0] = rvalue; obj[1] = userId; } 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 obj; }
From source file:com.mobilewallet.common.dao.ReferralIncentiveDAO.java
public Object[] addReferralIncetive(long userId, String refCode, String imei, String ip) { int added = 0; Connection connection = null; CallableStatement cstmt = null; String gcmId = null;// ww w.j a va 2 s . com Object[] obj = null; try { connection = dataSource.getConnection(); cstmt = connection.prepareCall("{call ADD_REFERRAL_CREDIT(?,?,?,?,?,?,?)}"); cstmt.setLong(1, userId); cstmt.setString(2, refCode); cstmt.setString(3, imei); cstmt.setString(4, ip); cstmt.registerOutParameter(5, java.sql.Types.INTEGER); cstmt.registerOutParameter(6, java.sql.Types.VARCHAR); cstmt.registerOutParameter(7, java.sql.Types.VARCHAR); cstmt.execute(); added = cstmt.getInt(5); gcmId = cstmt.getString(6); obj = new Object[3]; obj[0] = added; obj[1] = gcmId; obj[2] = cstmt.getString(7); } catch (Exception ex) { ex.printStackTrace(); log.error("Error in add referral incentive dao : " + ex.getMessage() + ", USER ID " + userId + ", refCode : " + refCode + ", imei : " + imei + ", IP : " + ip); } finally { try { if (cstmt != null) { cstmt.close(); } } catch (Exception ex) { } try { if (connection != null) { connection.close(); } } catch (Exception ex) { } } return obj; }
From source file:de.awtools.grooocle.varray.VarrayTest.java
@Test @Ignore// w w w . j a v a 2 s . c o m public void testOraclesVarrayWithPackage() throws Exception { CallableStatement cs = null; try { String arrayElements[] = { "Test3", "Test4", "Test5" }; // int n = OracleTypeCOLLECTION.TYPE_PLSQL_INDEX_TABLE; // ArrayDescriptor desc = ArrayDescriptor.createDescriptor(); ArrayDescriptor desc = ArrayDescriptor.createDescriptor("CP_TEST.t_ROWNUMBER", conn); ARRAY newArray = new ARRAY(desc, conn, arrayElements); String spCall = "{ call CP_TEST.call_me(?, ?) }"; cs = conn.prepareCall(spCall); cs.setArray(1, newArray); cs.registerOutParameter(2, java.sql.Types.INTEGER); cs.execute(); assertEquals(3, cs.getInt(2)); } finally { if (cs != null) { cs.close(); } } }
From source file:com.mobilewallet.users.dao.UserQuestionsDAO.java
public int submitQuestion(long userId, String question, String answerA, String answerB, String answerC, String answerD, String answer) { Connection connection = null; CallableStatement pstmt = null; ResultSet rs = null;//from www. j a v a 2 s . c o m int submitted = 0; try { connection = dataSource.getConnection(); pstmt = connection.prepareCall("{call submit_question(?,?,?,?,?,?,?,?)}"); pstmt.setLong(1, userId); pstmt.setString(2, question); pstmt.setString(3, answerA); pstmt.setString(4, answerB); pstmt.setString(5, answerC); pstmt.setString(6, answerD); pstmt.setString(7, answer); pstmt.registerOutParameter(8, java.sql.Types.INTEGER); pstmt.execute(); submitted = pstmt.getInt(8); } catch (Exception ex) { ex.printStackTrace(); } finally { try { if (rs != null) { rs.close(); } } catch (Exception ex) { } try { if (pstmt != null) { pstmt.close(); } } catch (Exception ex) { } try { if (connection != null) { connection.close(); } } catch (Exception ex) { } } return submitted; }
From source file:com.mobilewallet.users.dao.UserDAO.java
public int updateProfile(long userId, String mCode, String mobileNumber, String dob, String gender, String occupation, String income) { Connection connection = null; CallableStatement pstmt = null; ResultSet rs = null;/*from w w w . j a v a 2 s . co m*/ int updated = 0; try { connection = dataSource.getConnection(); pstmt = connection.prepareCall("{call UPDATE_PROFILE(?,?,?,?,?,?,?,?)}"); pstmt.setLong(1, userId); pstmt.setString(2, mCode); pstmt.setString(3, mobileNumber); pstmt.setString(4, dob); pstmt.setString(5, gender); pstmt.setString(6, occupation); pstmt.setString(7, income); pstmt.registerOutParameter(8, java.sql.Types.INTEGER); pstmt.execute(); updated = pstmt.getInt(8); } catch (Exception ex) { ex.printStackTrace(); } finally { try { if (rs != null) { rs.close(); } } catch (Exception ex) { } try { if (pstmt != null) { pstmt.close(); } } catch (Exception ex) { } try { if (connection != null) { connection.close(); } } catch (Exception ex) { } } return updated; }
From source file:Statement.Statement.java
private void load() { //Display dong Fix va Other Cost try {//w w w . j a v a 2 s . c o m PreparedStatement st = cnn .prepareStatement("select Fixed,Other from Expense where ShopID = ? and Date = ?"); st.setString(1, code); st.setString(2, date); ResultSet rs = st.executeQuery(); while (rs.next()) { txtFix.setText(customFormat("VND ###,###,###", rs.getInt(1))); fix = rs.getInt(1); txtOther.setText(customFormat("VND ###,###,###", rs.getInt(2))); other = rs.getInt(2); } } catch (SQLException e) { System.err.println(e.getMessage()); } //Display dong Revenue String query = "{call Revenue_Shop_Date(?,?,?)}"; try { CallableStatement cst = cnn.prepareCall(query); cst.setString(1, code); cst.setString(2, date); cst.registerOutParameter(3, INTEGER); cst.execute(); txtRev.setText(customFormat("VND ###,###,###", cst.getInt(3))); rev = cst.getInt(3); } catch (Exception e) { } //Display dong Profit cost = fix + other; profit = rev - cost; txtProfit.setText(customFormat("VND ###,###,###", profit)); //Display comment try { PreparedStatement st1 = cnn.prepareStatement("select Goal from Shop where ShopID = ?"); st1.setString(1, code); ResultSet rs1 = st1.executeQuery(); while (rs1.next()) { int goal = rs1.getInt(1); if (rev >= goal) { comment.setText("Congrats! The Shop has achieved the goal"); } else { comment.setText("The Shop has failed the goal"); } } } catch (SQLException e) { System.err.println(e.getMessage()); } }
From source file:com.mobilewallet.admin.dao.QuestionDAO.java
public int submitQuestion(String question, String qType, String option1, String option2, String option3, String option4, String answer, String explanation, String isAdminApproved) { Connection connection = null; CallableStatement pstmt = null; ResultSet rs = null;/*from ww w .j a v a 2 s . com*/ int submitted = 0; try { connection = dataSource.getConnection(); pstmt = connection.prepareCall("{call SUBMIT_QUESTION(?,?,?,?,?,?,?,?,?,?)}"); pstmt.setString(1, qType); pstmt.setString(2, question); pstmt.setString(3, option1); pstmt.setString(4, option2); pstmt.setString(5, option3); pstmt.setString(6, option4); pstmt.setString(7, answer); pstmt.setString(8, explanation); pstmt.setString(9, isAdminApproved); pstmt.registerOutParameter(10, java.sql.Types.INTEGER); pstmt.execute(); submitted = pstmt.getInt(10); } catch (Exception ex) { ex.printStackTrace(); } finally { try { if (rs != null) { rs.close(); } } catch (Exception ex) { } try { if (pstmt != null) { pstmt.close(); } } catch (Exception ex) { } try { if (connection != null) { connection.close(); } } catch (Exception ex) { } } return submitted; }
From source file:DAO.Poll_Tbl_pkg.Poll_TblJDBCTemplate.java
public int create2(int uid, String cid_json, String title, String description, String qtn_json, String ans_json, String poll_link, String start_ts, String end_ts, int reward, String poll_type) { System.out.println("reached create2"); CallableStatement st; int pid = 0;/*from w w w . j a v a2s.c om*/ try { con = conn.getDataSource().getConnection(); System.out.println("15 dec 10am"); String sql = "{call createPoll2 (?, ? , ? , ? ,? ,? ,? ,? ,? ,? ,? ,?)}"; st = con.prepareCall(sql); //Bind IN parameter first, then bind OUT parameter st.setInt(1, uid); st.setString(2, cid_json); st.setString(3, title); st.setString(4, description); st.setString(5, qtn_json); st.setString(6, ans_json); st.setString(7, poll_link); st.setString(8, start_ts); st.setString(9, end_ts); st.setInt(10, reward); st.setString(11, poll_type); st.registerOutParameter(12, java.sql.Types.INTEGER); //Use execute method to run stored procedure. System.out.println("Executing stored procedure..."); st.execute(); pid = st.getInt(12); System.out.println("PID mila balle balle" + pid); con.close(); return pid; } catch (Exception e) { System.out.println("createPoll2 procedure error=" + e); return pid; } }