Showing posts with label jdbc. Show all posts
Showing posts with label jdbc. Show all posts

Sunday, March 11, 2012

Can't retrieve second resultset with jdbc sql server 2005 driver

Hi All,

My java application executes one stored procedure that returns two resultsets and then deal with data. The code actually is very simple

Statement stmt = con.createStatement(); con is database connection

ResultSet rs = stmt.getResultSet();

//Do something

rs.close();

rs = stmt.getResultSet();

//Do something

Then I got the error: The result set is closed.

The code worked well with jdbc sql server 2000 driver.

Thanks for your help.

Eric

Hello lxiao,

The syntax for getting the second result set is

if(stmt.getMoreResults())

stmt.getResultSet();

Keep in mind that the getMoreResults() methods takes multiple arguments which controls how visited result sets should persist. Those flags are:

CLOSE_CURRENT_RESULT

CLOSE_ALL_RESULTS

You can find more information about using multiple result sets objects at the following site http://msdn2.microsoft.com/en-us/library/ms378758.aspx

Regards,

Jaaved Mohammed

Can't retrieve second resultset with jdbc sql server 2005 driver

Hi All,

My java application executes one stored procedure that returns two resultsets and then deal with data. The code actually is very simple

Statement stmt = con.createStatement(); con is database connection

ResultSet rs = stmt.getResultSet();

//Do something

rs.close();

rs = stmt.getResultSet();

//Do something

Then I got the error: The result set is closed.

The code worked well with jdbc sql server 2000 driver.

Thanks for your help.

Eric

Hello lxiao,

The syntax for getting the second result set is

if(stmt.getMoreResults())

stmt.getResultSet();

Keep in mind that the getMoreResults() methods takes multiple arguments which controls how visited result sets should persist. Those flags are:

CLOSE_CURRENT_RESULT

CLOSE_ALL_RESULTS

You can find more information about using multiple result sets objects at the following site http://msdn2.microsoft.com/en-us/library/ms378758.aspx

Regards,

Jaaved Mohammed

Sunday, February 12, 2012

Can't get unicode strings using JDBC driver

Hi;

If I call the following to get a Statement, ResultSet.getString() works fine with unicode strings:
Statement stmt = conn.createStatement();

But If I use the following:
Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);

Then all chars > 127 are returned as an ? from ResultSet.getString().

I think this is a bug.

? - thanks - dave

ps - I believe it's the latest Sql Server 200 drivers - they are all dated 4/21/04|||David --

It looks like this was resolved in the microsoft.public.sqlserver.jdbcdriver forum. Let us know if you still have issues.

-shelby

Can't get unicode strings using JDBC driver

Hi;

If I call the following to get a Statement, ResultSet.getString() works fine with unicode strings:
Statement stmt = conn.createStatement();

But If I use the following:
Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);

Then all chars > 127 are returned as an ? from ResultSet.getString().

I think this is a bug.

? - thanks - dave

ps - I believe it's the latest Sql Server 200 drivers - they are all dated 4/21/04|||David --

It looks like this was resolved in the microsoft.public.sqlserver.jdbcdriver forum. Let us know if you still have issues.

-shelby

Friday, February 10, 2012

Can't get results from JDBC

I'm having problems getting query results for my web-app using jdbc. The connection I make to the server looks fine, but whenever I execute a query, I get no results. I'm using something like the code below:
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
con =
java.sql.DriverManager.getConnection(connectionUrl,userName,password);
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select * from someTable");
I'm using SQL Squirrel Client as a back-end interface, and it is using the same drivers that my web-app is using, and it has no problems getting results. But everytime, I try to query the database from the servlet that I wrote, the ResultSet that comes back has no results. The exact same query I execute using Squirrel Client, however, is getting the right results. Is there something that I'm missing?

This code looks fine -- if you're still having this issue can you post more of the actual servlet code?

-shelby

Shelby Goerlitz

Microsoft SQL Server Data Programmability

Can't get results from JDBC

I'm having problems getting query results for my web-app using jdbc. The connection I make to the server looks fine, but whenever I execute a query, I get no results. I'm using something like the code below:
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
con =
java.sql.DriverManager.getConnection(connectionUrl,userName,password);
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select * from someTable");
I'm using SQL Squirrel Client as a back-end interface, and it is using the same drivers that my web-app is using, and it has no problems getting results. But everytime, I try to query the database from the servlet that I wrote, the ResultSet that comes back has no results. The exact same query I execute using Squirrel Client, however, is getting the right results. Is there something that I'm missing?

This code looks fine -- if you're still having this issue can you post more of the actual servlet code?

-shelby

Shelby Goerlitz

Microsoft SQL Server Data Programmability