不仅是一个基本例子,而且学是JDBC调用SQL SERVER存储过程的例子:
package sh.arvato.ua.csat;
import java.sql.*;
public class SQLDBManager {
String RL = "jdbc:sqlserver://localhost:1433;database=mydb1";
String user = "sa";// user
String password = "sa";// password
Connection con;
//开始时间
String startTime;
//结束时间
String endTime;
public SQLDBManager(String startTime,String endTime) {
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
con = DriverManager.getConnection(RL, user, password);
executeSprocInParams(con,startTime,endTime);
con.close();// close conn
} catch (Exception ex) {
ex.printStackTrace();
} finally {
}
}
public static void main(String[] args) {
}
/**
* ���ý����������Ĵ洢���
* @param con
*/
public static void executeSprocInParams(Connection con
,String startTime
,String endTime) throws Exception{
PreparedStatement pstmt = con
.prepareStatement("{call dbo.updateAgentId(?,?)}");
pstmt.setString(1, startTime);
pstmt.setString(2, endTime);
pstmt.execute();
System.out.println("execute ok");
pstmt.close();
}
}
refurl:http://www.qqread.com/java/2008/04/w407397.html 调用sql存储过程的各种形态
http://blog.csdn.net/net_lover/article/details/1764117 java中调用存储过程