0

I want to test the connection so I am using the query: 'SELECT 1 FROM dual' to compare the value returned.

ResultSet rs = stmt.executeQuery("SELECT 1 FROM dual");

on doing rs.next() the exception thrown is:

java.sql.SQLException: Closed Connection: next

How can I get rs.getString(1) as 1 by executing the query?

LittleBobbyTables - Au Revoir
  • 32,008
  • 25
  • 109
  • 114
Ashish Anand
  • 3,531
  • 6
  • 34
  • 45
  • I don't understand what you're trying to do: if the connection is closed then you can't get the `next()`, if the connection is opened then why do you need the value `1` ? – A.B.Cade Mar 27 '12 at 14:08

1 Answers1

0

You cannot compare the value returned when checking the connection:
If the connection is closed then you get no results, more then that, you won't be able to even create the statement ...

In your code you might have the connection closed somewhere before the rs.next() command.

you can see here a post similar to what you need

Community
  • 1
  • 1
A.B.Cade
  • 16,735
  • 1
  • 37
  • 53