java中的JDBC oracle更新语句

时间:2015-04-19 21:22:51

标签: java oracle jdbc

有人可以告诉我为什么在ps.excuteUpdate声明失败了吗?它似乎工作并更改了数据库中的数据,但它在execute语句失败,不会让它执行另外两个ps1和ps2语句。

    buyStock.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            try {
                BuyStock();
            } catch (SQLException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }

        }
    });





public void BuyStock() throws SQLException, IOException{
 Connection conn = null;
 PreparedStatement ps = null;
 PreparedStatement ps1 = null;
 PreparedStatement ps2 = null;
 int i = 0;
 String username = UserLoginInfo.userEmail;
 int bank = 75000;
 String string1= "goog";
 int shares = 25;

 conn = ConnectionManager.getConnection();

 if (i == 0) {

    ps = conn.prepareStatement("UPDATE L1_Standings SET BANK = ? WHERE EMAIL = '" + username + "'");
    ps1 = conn.prepareStatement("UPDATE L1_Stocks SET TICKER_SYMBOL = ? WHERE EMAIL = '" + username + "'");
    ps2 = conn.prepareStatement("UPDATE L1_Stocks SET NUM_SHARES = ? WHERE EMAIL = '" + username + "'");

    ps.setInt(1, bank);
    ps1.setString(1, string1);
    ps2.setInt(1, shares);

    ps.executeUpdate();
    ps1.executeUpdate();
    ps2.executeUpdate();

    ps.close();
    ps1.close();
    ps2.close();

} else {
    System.out.println("False");
}

0 个答案:

没有答案