473,670 Members | 2,405 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

JDBC error

25 New Member
Hi Guy, I am using a JDBC connection to retrieve data and populate datasets. Having some problems with errors:
Error: java.sql.SQLExc eption: [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 2343
JosAH
11,448 Recognized Expert MVP
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
kierandes
25 New Member
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
2261
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 was working fine until a while ago. I haven't watched it recently, and haven't changed anything I am aware off right now. After I realized the problem I tried many 3.08 versions with the same symptom. Watch were it says "Unknown system variable...
5
10397
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? I got this mysterious error message below in my logs ( nothing visible
0
1968
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 SRVE0026E: -: java.lang.UnsatisfiedLinkError: SQLConnect at COM.ibm.db2.jdbc.app.DB2Connection.connect(DB2Connection.java:514) at COM.ibm.db2.jdbc.app.DB2Connection.<init>(DB2Connection.java:436)
0
3080
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 on Windows 2000 machines. I configured a connection pool data source using type 4 for a local test environment in WSAD 5.1.x, and a connection pool data source on the WebSphere Server too. Both data sources are accessing the same database.
3
7862
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 is db2c_DB2 50000/tcp) which hosts a web, named www.abc.com, using dynamic ip, like 1.2.3.4 for a week them 2.3.4.5 for another week when using JDBC within local-net by using,
3
4457
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 crashes. Subsequent connections receive the Caused by: COM.ibm.db2.jdbc.DB2Exception:
1
9014
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 Portal. Any Help Appreciated. Thanks in advance. Praveen Singh
9
3547
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 'Syntax error in CREATE TABLE statement' even though I am not creating a table, but a Database // - - - - - - - - - - - - sun.jdbc.odbc.JdbcOdbc aSQL=CREATE DATABASE dbtest; java.sql.SQLException:
3
22836
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, what are my options? Will I have to install db2 connect on every client machine that needs to connect to the DB2 servers? Is the DB2 Connect freely available or will we have to purchase it? I have also read on this group that we can install DB2...
0
6512
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 Hibernate data access; nested exception is org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update org.springframework.orm.hibernate3.HibernateJdbcException: JDBC exception on Hibernate data access; nested exception is...
0
8466
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8384
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8813
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8591
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8659
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7412
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6212
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5683
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4208
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...

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.