locked
Java application talking to a FoxPro database. RRS feed

  • Question

  • We have an application that is using Java persistence api, java-odbc driver with a foxpro database. There is another Foxpro native application that accesses one of the foxpro table concurrently. Occasionally they will access the same record. This concurrent access is being protected against in both the applications. However, sometimes due to timing the Java application and the Foxpro application will receive Internal Exception: java.sql.SQLException: [Microsoft][ODBC VisualFoxPro Driver]Record is not locked. during commiting the data. The issue we are struggling to fix is that java ends up holding the table exclusively and does not release it till the server process is killed and restarted. Has anyone used Java and Java Persistence API against Visual Foxpro database ?

    Thursday, July 12, 2012 4:39 PM

Answers

  • Since you are using ODBC driver I assume it is an old VFP version data (latest ODBC driver was version 6). Java should be able to use OleDb driver, prefer that one. I didn't use from Java but used (and using) from C# and have no problem. Since it works from C# I think it may be due to your connection string (are you using tables exclusively in the first place?).
    Friday, July 13, 2012 12:15 PM

All replies

  • Since you are using ODBC driver I assume it is an old VFP version data (latest ODBC driver was version 6). Java should be able to use OleDb driver, prefer that one. I didn't use from Java but used (and using) from C# and have no problem. Since it works from C# I think it may be due to your connection string (are you using tables exclusively in the first place?).
    Friday, July 13, 2012 12:15 PM
  • AmySEAI wrote:

    We have an application that is using Java persistence api, java-odbc
    driver with a foxpro database. There is another Foxpro native
    application that accesses one of the foxpro table concurrently.
    Occasionally they will access the same record. This concurrent access
    is being protected against in both the applications. However,
    sometimes due to timingthe Java application and the Foxpro
    application will receive Internal Exception: java.sql.SQLException:
    [Microsoft][ODBC VisualFoxPro Driver]Record is not locked. during
    commiting the data. The issue we are struggling to fix is that java
    ends up holding the table exclusively and does not release it till
    the server process is killed and restarted. Has anyone used Java and
    Java Persistence API against Visual Foxpro database ?

    Check your jdbc DSN, one of the options it shows is "Exclusive: yes/no", just set it to "no".
    If you don't use a DSN then you must find how to tell the JDBC driver to turn on "Exclusive" via the connection string, like in this example:

    final String DB_URL =
    "jdbc:odbc:Driver={Microsoft FoxPro VFP Driver (*.dbf)};" +
    "UID=;"+
    "Deleted=Yes;"+
    "Null=Yes;"+
    "Collate=Machine;"+
    "BackgroundFetch=Yes;"+
    "Exclusive=No;"+
    "SourceType=DBF;"+
    "SourceDB=<path to databass>";

    Tuesday, July 17, 2012 9:20 AM
  • Vilco in Italy wrote:

    If you don't use a DSN then you must find how to tell the JDBC driver
    to turn on "Exclusive"

    Sorry, obviously I meant "to turn OFF"

    Tuesday, July 17, 2012 9:57 AM
  • Yes, exclusive is set to off and we are using a named DSN.  Any other suggestions?
    Wednesday, July 18, 2012 4:31 PM