Hear us Roar
Article:
 |
|
Stored Procedures for Java Programmers
|
| Subject: |
|
getting resultsets from a MS-SQL Server stored proc |
| Date: |
|
2004-02-17 01:46:03 |
| From: |
|
_viv
|
|
|
|
I am learning how to use MS-SQL server stored procedures in a JSP (JRUn server). I am using a simple stored procedure:
CREATE PROCEDURE dbo.dp_testStored1 AS select top 10 * from _user
GO
JSP code:
CallableStatement toesUp = null;
try
{
// Setup the call.
toesUp = con.prepareCall("{call dp_testStored1()}");
toesUp.registerOutParameter(1, Types.OTHER);
toesUp.execute();
ResultSet rs = (ResultSet) toesUp.getObject(1);
while(rs.next())
{
out.println("First: "+rs.getString(1)+ " :::Second:" + rs.getString(2));
}
rs.close();
}
catch (SQLException e)
{
toesUp.close();
con.close();
}
I don't get any results. I tried to debug the JSP code and found that the JSP stops working after the following statement:
toesUp.registerOutParameter(1, Types.OTHER);
Can someone help me?
Thanks
|
|
| |