小编123*_*HIS的帖子

如何调用存储过程和准备好的声明

在下面的代码中,我想调用一个存储过程并执行一个Query.我正面临错误statement.executeUpdate();请帮助修复它.我不知道哪里出错了.

public void Dbexe() {

    Connection connection;
    connection = DatabaseConnection.getCon();
     CallableStatement stmt;
    try {
        stmt = connection.prepareCall("{CALL optg.Ld_SOpp}");
        stmt.executeUpdate();
        stmt.close();
    } catch (SQLException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

     System.out.println("Stored Procedure executed");

     //PreparedStatement statement = null;
    // ResultSet rs = null;

    try{


     PreparedStatement statement;
    try {
        statement = connection.prepareStatement("MERGE INTO OPTG.R_VAL AS TARGET USING" + 
              ........... +
             "");

         statement.executeUpdate(); //Here the exception is thrown  
         statement.close();

         connection.commit();
         connection.close();


    } catch (SQLException e) {
        // TODO Auto-generated …
Run Code Online (Sandbox Code Playgroud)

java sql db2 stored-procedures jdbc

-3
推荐指数
1
解决办法
2万
查看次数

标签 统计

db2 ×1

java ×1

jdbc ×1

sql ×1

stored-procedures ×1