public void division(){
//获取要导入的总的数据条数
String sql3="SELECT count(*) FROM [CMD].[dbo].[mycopy1]"
try {
pss=cons.prepareStatement(sql3)
rss=pss.executeQuery()
while(rss.next()){
System.out.println("总记录条数:"+rss.getInt(1))
sum=rss.getInt(1)
}
//每30000条记录作为一个分割点
if(sum>=30000){
n=sum/30000
residue=sum%30000
}else{
就是通过JDBC的连接数据库,调用存储过程方式,只是需要把返回参数给标注一下。以下是在网上找的示例代码:Class c = Class.forName("oracle.jdbc.driver.OracleDriver")
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:ORCL","HH","HH")
CallableStatement cstmt = conn.prepareCall("{call TEST_CURSOR.TEST(?)}")
cstmt.registerOutParameter(1,oracle.jdbc.OracleTypes.CURSOR) //输出参数需要注册
cstmt.execute()
ResultSet rs = (ResultSet)cstmt.getObject(1) //注意是getObject,没有getCursor这种方法
while(rs.next())
{
System.out.println("id:"+rs.getInt(1)+" name:"+rs.getString(2)+" grade:"+rs.getInt(3))
}
摘抄至:http://blog.chinaunix.net/uid-8824503-id-2453541.html
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)