Call a stored procedure with no parameters and return value.
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
public class Main {
public static void main(String[] argv) throws Exception {
Connection con = null;
CallableStatement proc_stmt = null;
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
con = DriverManager.getConnection("jdbc:sqlserver://MYSERVER;databaseName=MYDATABASE",
"USERID", "PASSWORD");
proc_stmt = con.prepareCall("{ call someStoredProc() }");
proc_stmt.executeQuery();
}
}
Related examples in the same category