473,388 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

JDBC error

Hi Guy, I am using a JDBC connection to retrieve data and populate datasets. Having some problems with errors:
Error: java.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid cursor state

Expand|Select|Wrap|Line Numbers
  1.           // now we can get the connection from the DriverManager
  2.             Connection con = DriverManager.getConnection(database ,"","");
  3.  
  4.                 //String searchPatients = G.PatientSearch.getText();
  5.  
  6.             // We are connected, so lets create a statement to ask for names from our table "names"
  7.             Statement s = con.createStatement();
  8.             Statement s2 = con.createStatement();
  9.  
  10.  
  11.             s.execute("select Username  from Usernames");
  12.             s2.execute("select Password from Usernames");
  13.  
  14.             // Execute and get the results
  15.  
  16.             //rs2 is to get the Ward of the patient
  17.             ResultSet rs = s.getResultSet();// Patient Name Verification
  18.             ResultSet rs2 = s2.getResultSet(); // Ward name
  19.  
  20.             if (rs != null) {
  21.                 // If we had results, loop through them...
  22.                 while ( rs.next() )
  23.                 {
  24.  
  25.  
  26.  
  27.                    // resultset1 = rs.getString(1);
  28.                String RS2,strUsername, strPassword;
  29.  
  30.                 RS1 = rs.getString("Username" );
  31.                  RS2 = rs2.getString("Password" );
  32.                  strUsername = txtUsername.getText();
  33.                  strPassword = txtPassword.getText();
  34.  
  35.                 //SearchString = txtSearch.getText();
  36.                 int rowNum;
  37.                 int rowFind;
  38.  
  39.  
  40.  
  41.  
  42.                     // Just prints out the values
  43.                   if(RS1.equals(strUsername))// Filters by Name
  44.                  {
  45.                   //First check that the name is on the list
  46.                     System.out.println(strUsername);// rints the name
  47.  
  48.                  //  int rowrs1 =  rs.getRow();// Get the row number of the successful entry
  49.  
  50.                    // the next part gets the Ward of the patient
  51.                    // all depending on the row number of the first condition set
  52.                    // with rs - the first result set.
  53.                    // I got the row number of the set then
  54.                    // when rs2 cycles through the database, if its row number
  55.                    // is equal to the row number of the first rs - row number successful search
  56.                    // it will print the details, eg ward and later on the room number
  57.  
  58.                   // int rowrs3 =  rs3.getRow();// gets the row number of the 3rd result set
  59.                   // while ( rs2.next() )
  60.  
  61.                    //                 {
  62. //                     System.out.println("success");
  63.  
  64.                     //                }// end of rs3 While statement
  65.                   } //end of if on result set1 Name Filter
  66.  
  67.  
  68.  
  69.  
  70.                 }
  71.             }
  72.  
  73.             // Cleanup our statement and connection by closing them.
  74.             s.close();
  75.             con.close();
  76.         }
  77.  
  78.         // If there was an error connection or querying, show the error.
  79.         catch (Exception e) {
  80.             System.out.println("Error: " + e);
  81.         }
  82.  
  83.  
  84.  
  85.  
  86.  
  87.     return null;
  88.  
  89.     }
  90.  
Maybe there is something I am missing. any help would be greatly appreciated.
Mar 22 '09 #1
2 2330
JosAH
11,448 Expert 8TB
Make your code print out the complete stack trace; it contains line numbers and all; in your catch clause do this:

Expand|Select|Wrap|Line Numbers
  1. e.printStackTrace();
  2.  
... so you can see where exactly that exception was thrown.

kind regards,

Jos
Mar 22 '09 #2
Thanks Jos,
I'll implement that right away :)
Mar 22 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Nils Valentin | last post by:
Hi MySQL Fans ;-), Is it possible that the 3.08 series allows to connect to 4.0.14 versions but not to the 4.1 alpha-versions ? I get belows error when tryig to connect from DbVisualizer which...
5
by: Steve | last post by:
Hi; I went to the microsoft site to try to find a guide to the error messages that the jdbc drivers give ( for sqlserver 2000 ). I had no luck. Does anyone know if there is such a guide? ...
0
by: global | last post by:
Hi, can anyone help me I'm on Linux with UDB Runtime-Client 8.1.4 and try to connect to a windows udb-server 8.1.4 via Websphere and jdbc , and get this error: 3e1a29e5 WebGroup E...
0
by: Bing | last post by:
Hi, I am configuring the same DB2 v8.1 JDBC universal driver (db2jcc.jar and db2jcc_license_cisuz.jar) from DB2 SP5 fix pack under WSAD 5.1.x environment and WebSphere application Server 5.0.2...
3
by: John | last post by:
Hi All I'm new to set up DB2 though using JDBC for years. my question is: supposed there are 3 computers in local-net, named A,B,C (they are Windows 2000 families). DB2 installed in A (port...
3
by: deegs_ca | last post by:
Here is my jdbc info url = jdbc:db2://LXPP04913:60000/TEST driver = COM.ibm.db2.jdbc.net.DB2Driver For some reason as I'm importing data via a jdbc client Db2 gets through a few rows and then...
1
by: Praveen | last post by:
Hi, I have installed WebSphere Portal on AIX and connected to DB2 on a remote machine, Getting the followin errors when trying to get the values from database thru applications installed on...
9
by: Albretch | last post by:
.. I am trying to create a database in a MS Access DB via JDBC drivers. I have tried both sun.jdbc.odbc.JdbcOdbcDriver and ids.sql.IDSDriver From some reason both drivers Exceptions tell me...
3
by: Anoop | last post by:
Is it true that there are no type 4 jdbc drivers to connect to a DB2 server v7.1? The DB2 server is hosted on ACF2 (OS/390). We would be connecting from windows and solaris boxes. If it is true,...
0
by: neuraljay | last post by:
hi everyone. I am trying to build a jsp using webwork, hibernate and mysql. And right now I am doing its unit testing. Everytime I run the test I am getting this error: Error JDBC exception on...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.