Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Two ResultSet pointing to a table

  Asked By: Koila    Date: May 14    Category: Java    Views: 770
  

I wan to have two ResultSet pointing to a table,
or two ResultSet which each of them points to one
table , I have written the following code for the
first case, but I throws me an exception, would you
please let me know if the code is right, or if it
isn’t correct, please let me know the right code?

Here is the code,

String url = "jdbc:odbc:LocalServer";
String query = "SELECT * FROM t1 ORDER BY phrase
ASC";
String query1="SELECT * from X ORDER BY phrase1
ASC";
try {
Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection
(url);

Statement stmt = con.createStatement ();

ResultSet rs = stmt.executeQuery (query);
ResultSet rs1=stmt1.executeQuery(query1);

while(rs.next()){

System.out.println("hello");
} //while

stmt.close();
con.close();

} //try

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Ruairidh Anderson     Answered On: May 14

One big problem is
you are using two Resultset.
remove one Resultset
and run it.
It will work
Your code  is perfectly right.
You should display or complete the work before execute the second ResultSet.
After completing the while (rs.eof) you can create second ResultSet

 
Didn't find what you were looking for? Find more on Two ResultSet pointing to a table Or get search suggestion and latest updates.




Tagged: