首页 > 代码库 > 使用CallableStatement的用法

使用CallableStatement的用法

package Test;

import java.sql.*;

public class Test7 {
public static void main(String[] args) {
Connection con=null;
CallableStatement csta=null;

try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
con=DriverManager.getConnection("jdbc:sqlserver://localhost:1433;databaseName=stuDB","sa","123456");
csta=con.prepareCall("{call sho(?)}");
csta.registerOutParameter(1, java.sql.Types.INTEGER);
csta.execute();
System.out.println(csta.getInt(1));
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}


}

}

使用CallableStatement的用法