3.sql server的stored procedure例子:
import java.sql.*;
public class StoredProc0 {
public static void main(String[] args) {
String dbUrl = "jdbc:jtds:sqlserver://localhost:1433/qixytest";
String user = "sa";
String password = "";
try {
Class.forName("net.sourceforge.jtds.jdbc.Driver");
Connection con = DriverManager.getConnection(dbUrl, user, password);
System.out.println("Connection is ok");
CallableStatement cs = con.prepareCall("{call all_books}");
ResultSet rs = cs.executeQuery();
while(rs.next()){
System.out.println(rs.getString("BookName") + " " +
rs.getString("Authorname") + " " +
rs.getInt("numbersold"));
}
rs.close();
cs.close();
con.close();
}
catch (Exception e) {
e.printStackTrace();
}
文章转载自原文:https://blog.csdn.net/qq_44594249/article/details/100666192