473,385 Members | 1,317 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,385 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 2329
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.