我正在开发使用 java 开发的 Web 应用程序项目。在我的工作项目中,我需要在用户注册后动态创建数据库。我已经完成了这种方法。
但是,现在我想调用另一个模式(主数据库)中可用的一个存储过程。存储过程包含表。现在,我想在动态创建的数据库中调用该过程。
我已经编写了如下代码,任何人都可以帮助我知道这段代码有什么问题,
Connection c1 = DriverManager.getConnection(URL, USER, PASSWORD);
java.sql.CallableStatement cstmt=null;
System.out.println("Invoking the stored procedure from subscription DB........");
String callSP="{call masterdb.createCorporateDBProc()};";
cstmt= c1.prepareCall(callSP);
cstmt.execute();
java.sql.CallableStatement cstmt=null;
try {
System.out.println("Invoking the stored procedure from subscription DB........");
String callSP="{call subscription.createCorporateDBProc()}";
cstmt = c1.prepareCall(callSP);
int r = cstmt.executeUpdate();
System.out.println("SP created"+r);
System.out.println("SP invoked and executed successfully in corporate DB....");
} catch(com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException e){
e.printStackTrace();
cstmt.close();
c1.close();
}