Invalid Handle SQLException - HELP!!

I am using a timer and a counter to automaticallyinsert records into my table at predefined intervals. The counter is used to provide the unique PersonID. My first record is inserted fine, where PersonID is 0. As soon as PersonID is 1 or more, I get an Invalid Handle SQLException.
The line which is generating the error is:
stmt.setInt(1, id);
Relevent code is given below:
     * Insert a record into the Person table,
    private void insertPersonRecord(int id) {
        try {
            connection.setAutoCommit(false);
System.err.println("ID: " + id);
            stmt.setInt(1, id);
            stmt.setString(2, "First_name");
            stmt.setString(3, "Sur_name");
            stmt.executeUpdate();
            connection.commit();
            connection.setAutoCommit(true);
            stmt.close();
System.err.println("Person record inserted");
        catch(SQLException sqlex) {
System.err.println("Unable to insert person record");
            sqlex.printStackTrace();
     * Set up timer actions.
    class InsertTask extends TimerTask {
        public void run() {
            insertPersonRecord(id);
            id++;
            if (id == 20) {
System.err.println("Timer stopped - shutting down");                   
                shutDown();
    }I just can't work this out. Any ideas?
Cheers,
Sandra.

More code:
* Simple JDBC prototype using the Sports.mdb MSAccess database.
public class JDBCPrototype {
    private Connection connection;
    private PreparedStatement stmt;
    private Timer timer;
    private int id = 0;
    public JDBCPrototype() {
        // Connect to the Sports database using a JDBC-ODBC bridge.
        final String url = "jdbc:odbc:Sports";
        final String username = "JDBCPrototype";
        final String password = "test";
          // Load the driver to allow connection to the database          
        try {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            connection = DriverManager.getConnection(url, username, password);
System.err.println("Connection established");           
        catch (ClassNotFoundException cnfex) {
System.err.println("Failed to load JDBC/ODBC driver.");
            cnfex.printStackTrace();
            System.exit(1);
        catch (SQLException sqlex) {
System.err.println("Unable to connect");
            sqlex.printStackTrace();
        String insertString = "INSERT INTO PARTICIPANTS " +
            "VALUES (?, ?, ?)";
        try {
            stmt = connection.prepareStatement(insertString);    
        catch(SQLException sqlex) {
            sqlex.printStackTrace();
System.err.println("Unable to prepare statement");           
        //empty database
        try {
            Statement statement = connection.createStatement();
            statement.executeUpdate
                    ("DELETE * FROM PARTICIPANTS");
System.err.println("Table emptied");
        catch(SQLException sqlex) {
System.err.println("Unable to empty table");
            sqlex.printStackTrace();
        startTimer();
     * Insert records using the timer.
    private void startTimer() {
          timer = new Timer();       
        final int DELAY = 50;
        timer.schedule(new InsertTask(), 0, DELAY);    
System.err.println("Timer started");
    }   

Similar Messages

  • First Chance exception in build.exe(NTDLL.DLL);0xC0000008:Invalid Handle

    Hi Michael,
                               I am using WINDOWS XP with SP2 ; I am facing a problem after installing Sp6 for VC++
                 First Chance exception in build.exe(NTDLL.DLL);0xC0000008:Invalid Handle
         Please Help me out for this Michael.
    Thanks & Regards,
    Rakesh
    Rakesh

    Howdy Rakesh,
    I'm not sure who Michael is, but you might want to try the MSDN or the MSDN forum for general VC++ help.
    Warm regards,
    pBerg

  • Invalid handle to path? Help!

    I dowloaded a program LOGOS and it keeps on crashing. Their tech people said it came down to this problem. Can anyone help me with this 'path'? She said it may be something with LION and not being downloaded properly?
    Error detail: IOException: Invalid handle to path "/var/folders/15/bq7_xhf94zv6z1byk1rvjmf00000gn/T/tmp7bcd7658.tmp"

    Run through this list of fixes, I suspect by #8 all will be well.
    Step by Step to fix your Mac

  • Invalid handle to path? Help please!

    I dowloaded a program LOGOS and it keeps on crashing. Their tech people said it came down to this problem. Can anyone help me with this 'path'? She said it may be something with LION and not being downloaded properly?
    Error detail: IOException: Invalid handle to path "/var/folders/15/bq7_xhf94zv6z1byk1rvjmf00000gn/T/tmp7bcd7658.tmp"

    Is this still an issue (it's been a while since this was posted)?  If so, I'd encourage you to post on the Logos community forums or to call Logos customer support.
    I happen to know that a very similar issue was recently fixed for a customer by restarting the indexer.

  • Portlet Invalid handle exception -- URGENT PLEASE HELP

    I am deploying our Portal application and portlets in a clustered environment. We have three machines and following weblogic servers are started in each machine:
    Machine1 - Admin Server
    Machine2 - Portal1, Portlet1
    Machine3 - Portal2, Portlet2
    Portlets are deployed on portlet servers (portlet 1 and portlet 2). When I deployed the Portal application I intentionally registered portlet producer pointing to 127.0.0.1:8889, thinking that it will work for both portals since the portlet server is in same machine as well..
    So my assumption is :
    Portal1 will always load portlet from Portlet1 server and
    Portal2 will always load portlet from Portlet2 server
    but I am getting following error now... don;t have a clue what to do.. This is very urgent, I am working over the weekend over this.. any help would be highly appreciated..
    Line: -----
    <Apr 23, 2011 6:17:07 PM EDT> <Error> <oracle.portlet.client.connection.wsrp.HTTPClientTransport> <WCS-40152> <A request to the producer URL "http://127.0.0.1:8889/ApplicationAccess/portlets/WSRP_v2_Markup_Service" resulted in a status 500 response with fault string "Invalid handle "C:f5163bc7-4caa-4d4f-b031-cf475ecd099f".; nested exception is:
         oracle.portlet.producer.container.ContainerObjectNotFoundException: Object named "registration" could not be found in the persistent store.". The fault code given was "{urn:oasis:names:tc:wsrp:v2:types}InvalidRegistration". The producer generated a timestamp of 2011-04-23T18:17:06.217-04:00 and associated the following stack trace with the fault message: com.bea.wsrp.faults.InvalidRegistrationException: Invalid handle "C:f5163bc7-4caa-4d4f-b031-cf475ecd099f".; nested exception is:
         oracle.portlet.producer.container.ContainerObjectNotFoundException: Object named "registration" could not be found in the persistent store.
         at com.bea.wsrp.producer.handlers.management.ProducerDataStoreManager$ConfigurationContext.createWsrpFaultException(ProducerDataStoreManager.java:1481)
         at oracle.portlet.producer.container.persistence.WsrpFaultExceptionFactory.createWsrpFaultException(WsrpFaultExceptionFactory.java:43)
         at oracle.portlet.producer.container.persistence.PersistentProducerDataStore.getRegistrationDataContext(PersistentProducerDataStore.java:205)
         at oracle.portlet.producer.container.persistence.ProducerDataStoreImpl.getRegistrationDataContext(ProducerDataStoreImpl.java:225)
         at com.bea.wsrp.producer.handlers.management.ProducerDataStoreManager.initializeRequestContext(ProducerDataStoreManager.java:242)
         at com.bea.wsrp.producer.handlers.management.ProducerDataStoreManager.initializeRegistration(ProducerDataStoreManager.java:210)
         at com.bea.wsrp.producer.handlers.RegistrationHandleFilter.doFilter(RegistrationHandleFilter.java:56)
         at com.bea.wsrp.producer.handlers.AbstractServiceHandler.preprocess(AbstractServiceHandler.java:108)
         at com.bea.wsrp.producer.handlers.AbstractServiceHandler.service(AbstractServiceHandler.java:65)
         at com.bea.wsrp.producer.container.ProducerEndPoint.processNow(ProducerEndPoint.java:349)
         at com.bea.wsrp.producer.container.ProducerEndPoint.processNow(ProducerEndPoint.java:250)
         at com.bea.wsrp.producer.container.ProducerEndPoint.processNow(ProducerEndPoint.java:208)
         at oracle.portlet.server.adapter.web.WSRP_v2_Markup_PortTypeSoapToEndpoint.initCookie(WSRP_v2_Markup_PortTypeSoapToEndpoint.java:281)
         at oasis.names.tc.wsrp.v2.bind.runtime.WSRP_v2_Markup_Binding_SOAP_Tie.invoke_initCookie(WSRP_v2_Markup_Binding_SOAP_Tie.java:295)
         at oasis.names.tc.wsrp.v2.bind.runtime.WSRP_v2_Markup_Binding_SOAP_Tie.processingHook(WSRP_v2_Markup_Binding_SOAP_Tie.java:1448)
         at oracle.j2ee.ws.server.StreamingHandler.handle(StreamingHandler.java:299)
         at oracle.j2ee.ws.server.JAXRPCProcessor.doEndpointProcessing(JAXRPCProcessor.java:442)
    Line: -----
    Regards,
    sak007
    Edited by: user469829 on Apr 23, 2011 4:23 PM

    Sak007,
    Did u get the solution for this issue? I am also facing the similar kind of issue.
    I have a portal server, that consumes the remote portlet which is deployed on a cluster environment (Server1 and Server2). When i register my remote portlet, sometimes the registration handle holds info about server1 and sometimes it is server2. When the registration handle holds info about Server1, my application is working fine in the portal. Whereas when the registration handle holds the info about Server2. It throws the exception as:
    Invalid handle "C:10.10.0.42:-a3eb70c:130d71f8067:-7ff9".[[
    oracle.portlet.server.containerimpl.ContainerObjectNotFoundException: Object named "registration" could not be found in the persistent store.
    at oracle.portlet.server.containerimpl.persistence.SimplePersistentStorage.get(SimplePersistentStorage.java:47)
    Any pointers will be helpful.
    Note: I have visited the URl posted in above thread and it doesn't solve the issue.
    Thanks.

  • Question: I am trying to install Itunes via my external E drive , due to company retrictions on my laptop, when i try to boot up itunes via the desktop shortcut , I get invalid Handle e:/program/itunes . can anyone help.

    Question : I have just installed I Tunes to my external E drive , this is due to company laptop restiction with ref to software.
    When I try and load ITunes via my desktop short cut i get a window indicating Invalid handle e:/program/itunes. Can anyone offer any advise.

    iTunes needs to be installed on the boot drive.

  • Invalid Handle SQL Exception

    Everytime I call this method from my JSP page, I get the error Invalid Handle. I changed my query statement at the most bottom part to a hard-coded update statement (this one update wirtech.orders_temp set BOOKCODE ='12345678', QUANTITY = '150', SUPPLIER = 'rain', STAT = 'pending', FULFILLED = '0', CONSOLIDATED = '1', CONSOLIDATEID ='1' where POID = '10003) but i still get that error. I traced my program and found out the error comes out at After System.out.println("hereba2"+query);. That's the line before stmt.executeupdate(query); at the bottom part of the consolidatePOS method.
    Please help, we've been stuck here for one week already.
         public void consolidatePOS(Vector v, String code)
              try{
                   String poidfinal = "";
                   int y = 0;
                   int qty = 0;
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                   con = DriverManager.getConnection(url, username, password);
                stmt = con.createStatement();
                System.out.println("before big while."+v.size());
                   while(y<v.size())
                query = "select QUANTITY from wirtech.orders_temp where POID = '"+v.elementAt(y)+"'";
                System.out.println("first stmt.execute");
                rs=stmt.executeQuery(query);
                System.out.println("inside medium while.");
                while (rs.next())
                     System.out.println("inside small while.");
                     qty = qty + rs.getInt("QUANTITY");
                if(y == v.size()-1)
                     poidfinal = ""+v.elementAt(y);
                y++;
                rs.close();
                System.out.println("after big while.");
                int ea = getConsolidateID();
                System.out.println("ea"+ea);
                System.out.println("here ba/!?");
                query = "update wirtech.orders_temp set BOOKCODE ='12345678', QUANTITY = '150', SUPPLIER = 'rain', STAT = 'pending', FULFILLED = '0', CONSOLIDATED = '1', CONSOLIDATEID ='1' where POID = '10003'";
                System.out.println("here ba2"+query);
                stmt.executeUpdate(query);
                System.out.println("after big while. LASTT");
                stmt.close(); con.close();
                } catch(Exception ex) {
                     System.out.println("error in consolidatePOS()" + ex);     
              public int getConsolidateID()
              {int x =0;
                   try {
                Class.forName(driver);
                con = DriverManager.getConnection(url, username, password);
                stmt = con.createStatement();
                query = "SELECT COUNT(DISTINCT CONSOLIDATEID) AS count FROM wirtech.orders_temp";
                rs = stmt.executeQuery(query);
                while (rs.next()) {
                    x = rs.getInt("count");
                rs.close();
                stmt.close();
                con.close();
            } catch (Exception e) {
                System.out.println("getTransactionCount has an Exception: " + e);
            }

    This is a complete guess! ... perhaps the
    rs.close();also closes the Statement (or invalidates it) which you use later to execute the update. The API does not seem to indicate this though:
    void close()
               throws SQLException
        Releases this ResultSet object's database and JDBC resources immediately instead of waiting for this to happen when it is automatically closed.
        Note: A ResultSet object is automatically closed by the Statement object that generated it when that Statement object is closed, re-executed, or is used to retrieve the next result from a sequence of multiple results. A ResultSet object is also automatically closed when it is garbage collected. But perhaps it may still be worthwhile seeing if removing that close will fix the problem.

  • Invalid Handle Exception-What is the reason?

    I face with "Invalid Handle exception" (SQLException) while using the following code.
    Could anybody tell me the possible reasons/Situation the error rise?
    stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery(SQLStmt);
         if(rs!=null){
    ResultSetMetaData rsm = rs.getMetaData();
         int totalcols = rsm.getColumnCount();
         Vector temp;
         while (rs.next()) {
         Vector temp = new Vector();
         for (int i = 1; i <= totalcols; i++) {
              String value = rs.getString(i);
              if (value == null) {
              value = "";
         temp.addElement(value);
         }//for loop ends here
         valueVector.addElement(temp);
         rs.close();
         stmt.close();     
    Thank you all

    Vector temp;
    while (rs.next()) {
    Vector temp = new Vector();Are you sure that this is the code you are running? The reason I ask is that I'm pretty sure that it won't compile, at least under JDK1.4. You should get a compile error something like "temp is already defined".
    If thats not the problem you need to find out on which line the error actually occurs. You can get this from the exception by calling the printStackTrace() method.
    Col

  • Why do I get an invalid handle error when debugging, on a call to ncReset?

    I am working with the example program obj2obj.c
    I have a PCI-CAN/2 card installed.
    I must call ncReset for *both* ports (CAN0 and CAN1), prior to any other commands or I will get a driver error (NC_ERR_DRIVER, Bxxx0002).
    This happens even if the program terminates properly, closing all handles, and I then remove the ncReset commands.
    Fine, I can live with the ncResets.
    However, if I then try and debug the program using Microsoft Visual C++, it immediately chokes on the second call to ncReset( "CAN1", 0 ) and complains about an invalid handle.
    If I add a status check to both of the ncResets and run the program from the DOS command line, I don't get any errors printed out
    so the calls are working fine just running the program.
    The driver updates listed do not appear to address this problem (1.4.1 uses LabView which I do not have and 1.4.2 is for Windows 2000)
    Why are the ncResets required in the first place?
    And why can't I single step through the second call to ncReset?
    Thanks in advance for your help.
    System details:
    PC running Windows NT 4.00.1381
    PCI-CAN/2 w/driver 1.4
    Microsoft Visual C++ 6.0 Professional

    bsat, thank you for helping out!
    I had tried using only one ncReset previously and was experiencing driver errors. I removed the second ncReset as you suggested and now it seems to work with only one. I cannot get it to fail like it was doing.
    However, at least one ncReset must be used or I get the following error:
    ERROR ncConfig CAN1: Driver error (qual=000b000)
    Press any key to continue
    I get this error even when the program terminates normally. For example:
    1) Build obj2obj with the ncReset command.
    2) Execute and allow to terminate normally.
    3) Edit obj2obj and remove ncReset command.
    4) Execute and the error message is displayed.
    Amazingly, I was also able to single step through most of the program this morning. I got the first three messages (of 10 total) before ge
    tting the error:
    Microsoft Visual C++
    First-chance exception in cctool.exe (NTDLL.DLL): 0xC0000008: Invalid Handle
    It seems to be more random than first appeared and perhaps more related to MSVC than to the NI-CAN card. Any insight?
    Also, having to include an ncReset is undesireable since I'd like to develop a CAN driver that could be called from multiple threads. I'd be very interested in your opinion on why I'm having trouble getting it to work without one.
    Thanks again for your help, it is greatly appreciated!

  • INVALID HANDLE

    PLEASE HELP ME
    I GOT EXCEPTION INVALID HANDLE IN MS ACCESS & MS SQL SERVER
    I MADE THE METHOD STATIC WHICH LOADS DRIVER & GET CONNECTION SO NEXT TIME IT WILL REUSE PREVIOS REFERANCE
    CODE:
    import java.sql.*;
    public class getconnection
    static Connection connection;
    static Statement st123;
    public getconnection()
    public static Statement getConnection() throws Exception
                   if(connection==null)
                        System.out.println("...............N e w - C o n n............. ");
                        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    connection = DriverManager.getConnection("jdbc:odbc:gandhiasso","","");
                        st123 = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
                        System.out.println(st123);
                   System.out.println("...............O l d - C o n n............. ");
                   return st123;
         public void closeConnection()throws Exception
    ONLY ONCE QUERY EXECUTES NEXT TIME IT SHOWS INVALID HANDLE FOR ANY QUERY
    PLZ PLZ HELP ME OUT

    >
    CODE:
    import java.sql.*;
    public class getconnection
    static Connection connection;
    static Statement st123;
    public getconnection()
    public static Statement getConnection()
    throws Exception
                   if(connection==null)
    System.out.println("...............N e w - C o n
    o n n............. ");
                        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    connection =
    DriverManager.getConnection("jdbc:odbc:gandhiasso","",
    st123 =
    23 =
    connection.createStatement(ResultSet.TYPE_SCROLL_SENSI
    TIVE,ResultSet.CONCUR_UPDATABLE);
                        System.out.println(st123);
    System.out.println("...............O l d - C o n
    o n n............. ");
                   return st123;
         public void closeConnection()throws Exception
    ONLY ONCE QUERY EXECUTES NEXT TIME IT SHOWS INVALID
    HANDLE FOR ANY QUERY
    PLZ PLZ HELP ME OUTI think it was the way you create the class and its constructors.
    I don't think you can create "static" method with a contructor name.
    Try changing your class and contructor to DBConnection, and leave the rest unchanged. See what happen..
    Good luck
    :D
    PS. next time, please use formatting tips. I've some difficulties understanding what you explained.

  • Invalid Handle Exception!

    Background: I have a SQL database created and maintained via MS Access 2003. I use JDBC to connect and interact with this database. So far my program has been able to do everything from querying a table to inserting new rows to deleting others, but has had no luck with updating rows either through the execute()/executeUpdate() methods or the ResulSet updateInt()/UpdateString() methods.
    So currently I'm recieving an Invalid Handle error during runtime for this program. I ran a stack trace and the line that gave the error was where I was creating a ResultSet from an executeQuery(). I'm unsure what Invalid Handle means, and am further baffled at this error since I have another method with the EXACT SAME line for the query and it receives no errors. To put it into better veiw I have my main class/main method, and from there I call a few different methods from this other class I have. I call this one method, works fine; I call this other method a little while afterwards and it has the exact same few lines at the beginning as the previously mentioned method. Suddenly I get this Invalid Handle error. Like I said, the error said it's happening when I'm doing ResultSet rs = stmnt.executeQuery("SELECT columns FROM table WHERE column LIKE 'string'");
    Please help! Thank you!

    i cant ever open adobe or other pdf files im not new to computers but i am far from profficient. when i ask adobe and others about invalid handles, broken ? whatever and dont have permission etc. all i get is silence or blank looks....i think adobe suks very hard and all the rest of this stuff is just terrible and i want to change to linux....i sure wish i knew more but when i ask a lot of people who claim to be knowledgable i find that all they can do is type well and open and parse documents where i know much more about most hardware and software......anyone out there able to help a dyslexic non typer???

  • I am using an iphone 3g and when i connect my device to my laptop a dialog box appears saying that an update of 4.2 is available so went for it.after the firmware is downloaded via itunes it shows that the firmware is invalid!.please help.

    HEY GUYS I AM USING AN IPHONE  3g and when i connect my device to my laptop a dialog box appears saying that an update of 4.2 is available so went for it.after the firmware is downloaded via itunes it shows that the firmware is invalid!.please help.
    AND ALSO I HAVE HEARD THAT THE IPHONE 3G CANNOT BE UPDATED TO IOS 4.2!IS IT TRUE???
    PLEASE HELP ME.

    This means that the phone you have was software unlocked to use on any carrier, or hacked. When you installed the update it restored the lock that originaly came with your phone. Not much you can do now. Apple will not support hacked phones. You will need to find out the carrier your phone is locked to and see if they offer official unlocking, or start googling to see if you can find a way to unlock 4.2.

  • Invalid Handle Exception grr.

    I get this every time i try to update my database. not when i read from it, that goes error free but writing to it, ug. Here's whats goin on:
    the setup for the table is:
    Verb Type
    String Integer
    Con is the Connection that is always successful when used to read data
    the Method FindData returns "Yes" if the verb exists in the table and "No" if it doesn't and yes i have my reasons for making it return a string instead of a boolean
    Command is a Statement: Statement Command = Con.createStatement();
    Update is a String
    i is an int
    if (FindData(Con, Verb).compareTo("No") == 0)
         Update = "insert into [Sheet1$] (Verb, Type) values('"+Verb+"', "+Integer.parseInt(Data)+")";
         System.out.println("Update: "+Update);
         i = Command.executeUpdate(Update);
         if (i == 1) System.out.println("Success!!!"); else System.out.println("Failed");
         Command.close();
         Con.close();
         System.out.println("EXISTS:: "+FindData(Con, Verb));                    
    here's what i get as output:
    ----jGRASP exec: java UpdateData
    Update: insert into [Sheet1$] (Verb, Type) values('Mentir', 1)
    Invalid handle
    ----jGRASP: operation complete.
    Which means it throws an exception at the i = Command.executeUpdate(Update); line and doesn't go further than that.
    Does anyone know what this function even means?
    Does anyone know how to fix this?
    if you need more information pleas let me know
    Thanks, Lateralus

    yep it's an excel driver that allows you to connect to excel databases. here's my getConnection function:
    public static Connection getConnection(String FilePath, String FileName)
         String Driver = "";
         String Url = "";
         String Username = "";
         String Password = "";
         Connection Con = null;
         try
              Driver = "sun.jdbc.odbc.JdbcOdbcDriver";
              Url = "jdbc:odbc:Excel Files;DBQ=";
              Url += FilePath+"\\"+FileName;
              Username = "";
              Password = "";
              Class.forName(Driver); // load JDBC-ODBC driver
              return DriverManager.getConnection(Url, Username, Password);
         catch (Exception e) {System.out.println("getConnection:  "+e.getMessage());}
         return(Con);
    }

  • Trying to redeem my digital copy of Star Trek, the movie, and iTunes tells me I've already redeemed it, or the redemption code is invalid. Any help woud be greatly appreciated

    Trying to redeem my digital copy of Star Trek, the movie, and iTunes tells me I've already redeemed it, or the redemption code is invalid. Any help woud be greatly appreciated

    You don't say which film you're struggling to download, I had problems with a-team and I ended up emailing the address on the leaflet, turns out they had a lot of problems  with people's codes,  they then gave me a new code to use! I have now managed to get the film downloaded?

  • After upgrading to iOS8 my Exchange account has changed to an invalid address. I can change it but after a day or two it changes back to the invalid address. any help on this would be great.

    after upgrading to iOS8 my Exchange account has changed to an invalid address. I can change it but after a day or two it changes back to the invalid address. any help on this would be great. Other user on our exchange server that have iOS 7 or lower do not have this problem. All iOS 8 users in our company have this problem

    have you deleted the account and re-added it?  Have you done a reset or restore as outlined in the iPhone user guide?  What troubleshooting have you done?

Maybe you are looking for