Question

I am trying to use DBF files from Java for newer utilities that interact with a large older system. I am able to access, read, write, update using the Java ODBC bridge but this does not update the NTX indexes. I found xbasej which claims to be able to use indexes but seems only to be able to use NDX indexes. I could always create them before using them but then it will still not update the NTX ones used by all the other programs. There are several thousand programs interacting here so just switching to NDX is not possible and I have no budget.

So my question is: Is there any way to make xbasej use NTX indexes or failing that is there any other free Java library that can auto update the NTX files if I open them all before editing the database?

Oh and I have forwarded port 6262, and even tested with my firewall off totally.

Any help will be most appreciated.

I have found the Sybase Advantage drivers link Which can apparently open DBF and NTX files, I can use their Data Architect program to create a data dictionary to access my data but I cannot work out how to use it from Java, all the examples seem to require some sort of server connection. Something like this should work:

try {
        Class.forName("com.extendedsystems.jdbc.advantage.ADSDriver");
    } catch (ClassNotFoundException ex) {
        Logger.getLogger(DBFTest.class.getName()).log(Level.SEVERE, null, ex);
    }

    try {
        ADSConnection conn = (ADSConnection) DriverManager.getConnection("jdbc:extendedsystems:advantage://localhost:6262;catalog=//llama-rog/c/stock/DD.add;user=master;password=master");   
    }catch (SQLException ex) {        
        Logger.getLogger(DBFTest.class.getName()).log(Level.SEVERE, null, ex);
    }        
}

Every time I attempt to connect I get:

com.extendedsystems.jdbc.advantage.ADSException: [iAnywhere Solutions][Advantage JDBC]Connection refused: connect
at com.extendedsystems.jdbc.advantage.n.<init>(Unknown Source)
at com.extendedsystems.jdbc.advantage.ADSConnection.<init>(Unknown Source)
at com.extendedsystems.jdbc.advantage.ADSDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager.java:579)
at java.sql.DriverManager.getConnection(DriverManager.java:243)
at dbftest.DBFTest.main(DBFTest.java:30)

I have searched for hours and come up totally dry for any example code to connect to a local only data dictionary (.add) which has my DBF and associated indexes listed. Someone mentioned using the alias that the Data Architect creates in ADS.ini but again there is no trace of how to do this. The Jar file does not come with a javadoc, only some HTML help files which I have trawled through and found nothing.

There is a tester app which supposedly lets you test out connections but still requires me to type in my connection string, user name and password and neither through data dictionaries nor free tables am I able to connect to anything, I always get the same error.

Does anyone have any idea how to get this working. The fact that it works through their data architect tool proves that it should work somehow but exactly how I can copy that functionality, I don't know.

Was it helpful?

Solution

The Advantage JDBC driver requires Advantage Database Server, which is the client-server version of the product. Based on the comment "no budget", I'm guessing you haven't purchased the server. If that is the case, then the JDBC driver will not be of any use to you. It seems likely that the Connection refused error is occurring because there is no server to accept the connection.

If you are able to use an ODBC bridge, then one possibility it to use the Advantage ODBC driver, which can connect to Advantage Local Server (the non-client-server version, which is free based on your usage ... read the license). You should be able to install the Advantage ODBC driver, set up a data source that specifies the data dictionary (using same path as you used with Advantage Data Architect).

You probably did this already, but when you created the data dictionary and added the tables, make sure you added the appropriate .ntx files for each table. Advantage has no way of figuring which indexes would belong to which table otherwise.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top