这是我的功能:
public static void execute_delete_on_db(String pass, String login, String port,
String host, String table_name, String file_path) throws Exception {
Class.forName("oracle.jdbc.OracleDriver");
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@//"
+ host + ":" + port + "/xe", login, pass);
PreparedStatement statement = null;
Statement stmt = null;
String query = "delete from AA_ALL";
stmt = conn.createStatement();
stmt.executeQuery(query);
sql_statement.close();
conn.commit();
conn.close();
}
至少这是我职责中最重要的部分。上面的代码工作正常。我尝试通过调用此 sql 语句来执行我的过程:
EXECUTE delete_all_rows_from_table('all');
在 Java 中它看起来像这样:
String query = "EXECUTE delete_all_rows_from_table('all')";
在数据库上它工作正常,但在 Java 中这给了我错误。
你能告诉我我做错了什么吗?
You can call
你的程序而不是像这样执行它:
String query = "{call delete_all_rows_from_table(?)}";
CallableStatement statement = connection.prepareCall(query);
statement.setString(1, "all");
statement.execute();
您可以在这里了解更多信息:JDBC CallableStatement – 存储过程 OUT 参数示例 https://www.mkyong.com/jdbc/jdbc-callablestatement-stored-procedure-out-parameter-example/ and JDBC 存储过程 https://www.tutorialspoint.com/jdbc/jdbc-stored-procedure.htm
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)