Menu

NumberFormatException during connectDb

Help
2015-03-19
2015-03-20
  • Wayne Johnson

    Wayne Johnson - 2015-03-19

    Hi, thanks for the new version. It gets me around my previous problem -- NOT NULL Constraint.

    Here's a new one. We use a database to record events during a mission, so I have many databases available to use. During connectDb() to some databases I get the following exception stack trace:

    net.ucanaccess.jdbc.UcanaccessSQLException
        at net.ucanaccess.jdbc.UcanaccessDriver.connect(UcanaccessDriver.java:247)
        at java.sql.DriverManager.getConnection(DriverManager.java:664)
        at java.sql.DriverManager.getConnection(DriverManager.java:270)
        at pocdb.PocDatabase.connectDb(PocDatabase.java:61)
        at pocdb.PocDatabase$1.run(PocDatabase.java:666)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:749)
        at java.awt.EventQueue.access$500(EventQueue.java:97)
        at java.awt.EventQueue$3.run(EventQueue.java:702)
        at java.awt.EventQueue$3.run(EventQueue.java:696)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:719)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
    Caused by: java.lang.NumberFormatException
        at java.math.BigDecimal.<init>(BigDecimal.java:494)
        at java.math.BigDecimal.<init>(BigDecimal.java:383)
        at java.math.BigDecimal.<init>(BigDecimal.java:806)
        at net.ucanaccess.converters.LoadJet$TablesLoader.value(LoadJet.java:971)
        at net.ucanaccess.converters.LoadJet$TablesLoader.loadTableData(LoadJet.java:728)
        at net.ucanaccess.converters.LoadJet$TablesLoader.loadTablesData(LoadJet.java:881)
        at net.ucanaccess.converters.LoadJet$TablesLoader.loadTables(LoadJet.java:925)
        at net.ucanaccess.converters.LoadJet$TablesLoader.access$3(LoadJet.java:919)
        at net.ucanaccess.converters.LoadJet.loadDB(LoadJet.java:1311)
        at net.ucanaccess.jdbc.UcanaccessDriver.connect(UcanaccessDriver.java:236)
        ... 18 more
    

    So far I put a breakpoint at BigDecimal.java:494 and looked at what variables I could see. The 'in' arg to BigDecimal is a char[] containing "NaN"! Don't know where that is coming from! I dumped the contents of the database (using Java7 and jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)}) to a txt file and can find no NaN's in it.

    Can you give me clues to find out what the problem is?

    Thanks.

     
  • Marco Amadei

    Marco Amadei - 2015-03-19

    Unfortunatly this is the first time a problem like that is reported.
    The value NaN(as float) is read by jackcess, no doubt about it. I know why it's passed as string, but I don't know why it's read by jackcess as a float NaN.
    I strongly suspect your db is corrupted, may you re-try after having used the Compact and Repair MS Access tool? Please, let me know you findings.
    Also, may you post along a db with a copy of the problematic table?

     
  • Wayne Johnson

    Wayne Johnson - 2015-03-19

    I found it!
    There is a NAN in the database. At least in 2 of the 10 or more I tried today. Deep in a table of 10000+ rows in a file of 150MB there was a single NAN. Don't know how it got there, but it's in 2 of them.
    Anyway, UCanAccess is off the hook for this, unless there may be some more gentle way to handle the situation and inform the user.
    Thanks, Marco.

     
  • Marco Amadei

    Marco Amadei - 2015-03-20

    I can fix ucanaccess to deal with bad data(and, of course, inform the user with a warning), but a fix is needed.
    Inserting NaN values doesn't seem to be allowed in access.
    However, I'll fix the handle of NaN asap.

     
  • Marco Amadei

    Marco Amadei - 2015-03-20

    fixed on svn trunk

     

Log in to post a comment.