resultRow = ""; for (int i = 1; i < cols; i++) { try { resultRow += results.getString(i) + ";"; } catch (NullPointerException e) { System.out.println(e.getMessage()); } } System.out.println(resultRow); } } catch (Exception e) { System.out.println("query exception"); } finally { results.close(); } } }
2004-1-16 补充高级内容
关于调用SQLServer存储过程的例子:(用到了我们开发的数据库连接类)
CREATE PROCEDURE [dbo].[sp_getStudentByName](@name char(10)) AS Select * from Students where [Name]=@name GO
DbObject DbO = new DbObject(new SqlServerConnectionFactory("localhost", 1433, "demo", "sa", "")); Connection con = DbO.getConnection(); CallableStatement pstmt = null; System.out.println("TestDB1()............"); /* try { pstmt = con.prepareCall("{call sp_getStudentById(?)}"); pstmt.setInt(1, 1);
上一篇:JAVA实例:学会数字签名
下一篇:Java学习:线程池的简单构建
|