Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
How to get a resultset from SQL server into java ?
I need to run a Stored Procedure in SQL server from Java and catch the resultset , and so far I wasnt able to .
can anybody give me an example ?
ResultSet rsCombo = null;
try{
cs = connSql.conSQLServer2.prepareCall("{call [dbo].[prscrapModulesList]}");
rsCombo = cs.executeQuery();
while (rsCombo.next()){
**** here shows an error
the stored procedure is...
PROCEDURE [dbo].[prscrapModulesList]
AS
select moduleid as id , moduleid as description, '-1' as cond1 from scrapmoduleload where moduleid not like '' order by moduleid
**** question ... do I need a cursor to send the resultset to Java ?
1 Answer
- 1 decade agoFavorite Answer
Obviously, you want to use JDBC. I assume you know how to do a query, and are just stuck on the stored procedure part.
You want to used CallableStatement. Something like this:
CallableStatement stmt = connection.prepareCall("{? = call "
+ your_stored_proc(?, ?, ?)}");
Everything else is pretty much the same as normal.
Good luck!