"Invalid cursor state" error

"Invalid cursor state" error

Post by dipen2.. » Wed, 10 Jan 2001 19:21:56



Hi,

When running the code below I get the following error:

java.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid cursor
state
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid cursor
state
        at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6031)
        at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:6188)
        at sun.jdbc.odbc.JdbcOdbc.SQLGetDataString(JdbcOdbc.java:3266)
        at sun.jdbc.odbc.JdbcOdbcResultSet.getDataString
(JdbcOdbcResultSet.java:5377)
        at sun.jdbc.odbc.JdbcOdbcResultSet.getString
(JdbcOdbcResultSet.java:320)
        at DBCompany.<init>(DBCompany1.java:177)
        at DBCompany.main(DBCompany1.java:207)

Can anyone tell me what I have missed out/done incorrectly?
Or, is there a limit to the number of resultsets you can have in one
java program?

Many Thanks in advance!
Dipen

Code
====
import java.sql.*;
import java.util.*;
import java.io.*;
import DBConnection;

public class DBCompany1
{

    public DBCompany1() throws IOException
    {
       String table, sqlstr = null;
       try
       {
          DBConnection db = new DBConnection();
          Connection conn = db.getConnection("abc","de");
          Connection connA = db.getConnection("abc","de");
          Connection connB = db.getConnection("abc","de");
          Connection conn2 = db.getConnection("cde","de");

          Statement st = conn.createStatement();
          sqlstr = "select * from companies";
          ResultSet rs = st.executeQuery(sqlstr);
          while(rs.next())
          {
             String company_id = rs.getString(1);

             Statement st2 = connA.createStatement();
             String sqlstr2 = "select * from sources";
             ResultSet rs2 = st2.executeQuery(sqlstr2);

             while(rs2.next())
             {
                String name = rs2.getString(1);
                String type = rs2.getString(2);

                Statement st3 = connB.createStatement();
                ResultSet rs3 = st3.executeQuery("select * from
sectors");

                while (rs3.next());
                {

// error occurs here - ie when trying to 'get' the datatype
                                  Object o = rs3.getObject(1);
                                  System.out.println("the datatype for
column 1 of rs3 is : " + o.getClass().getName());

                }
             }
          }
       }
       catch(SQLException e)
       {
          System.err.println(e);
                  e.printStackTrace(System.err);
       }
       catch(IOException e)
       {
                  System.err.println(e);
                  e.printStackTrace(System.err);
       }
   }

   public static void main (String[] args) throws IOException
   {
      DBCompany1 test = new DBCompany1();
   }

Quote:}

Sent via Deja.com
http://www.deja.com/
 
 
 

1. "Invalid cursor state" / Error 0x80004005

I have a routine as follows, which helps me to do query governing for a very
large database with free adhoc capability with web front end.
Below routine used to work on all IIS5 machines with Win2000 server with
sp1, MDAC 2.5.   Gradually it started not working on certain machines.
The issue is that at
    Set rsC = oCmdCost.Execute          line I get
********************************
Error Type:
Microsoft OLE DB Provider for SQL Server (0x80004005)
Invalid cursor state
/personSearchus.asp, line 27
********************************

sConnCost=
"server=myServer;uid=sa;pwd=;database=myDb;provider=SQLOLEDB;driver={SQL
Server};Connect Timeout=300;General Timeout=300;"
Set oConnCost = CreateObject(sCn)
oConnCost.Open sConnCost
oConnCost.CursorLocation = 3 :
Set oCmdCost = CreateObject(sCmd): oCmdCost.ActiveConnection = oConnCost
oCmdCost.CommandTimeout = 180 :
oCmdCost.CommandText = "set showplan_all off"
Set rsC = oCmdCost.Execute
oCmdCost.CommandText = "set showplan_all on"
Set rsC = oCmdCost.Execute
sSql =  "select distinct  top 500 idField from myTable where firstName
='jacko' and state = 'CA' and lastName like = 'K%'
oCmdCost.CommandText = sSql
oCmdCost.CommandType = 1
oCmdCost.prepared = false
Set rsC = oCmdCost.Execute
rsC.movelast
iCostRows = clng(rsC("EstimateRows"))

Heeeeeeeeeelp please.
What is file+version is causing this error.

Travis McGee
Nothing But Microsoft

2. Problems with sqleditor

3. SQL 7.0 error "Invalid Cursor State"

4. ODBC Recordset Question

5. "Invalid cursor state"

6. Quick Sort with PL/SQL or with Any Other Oracle Utilities?

7. ODBC "invalid cursor state"

8. FTP sites

9. "Invalid Cursor State" errors when creating tables in SQL7 Enterprise Manager

10. In VJ++ use JDBC get "invalid cursor state" error

11. "Invalid Cursor State" error message in Query

12. Error "Bad cursor state"

13. "Invalid Cursor Error"