Accessing text file via JDBC - Websphere

This is a discussion on Accessing text file via JDBC - Websphere ; We are trying to access text files using JDBC on a zLinux server. But, somehow we keep on getting a NullPointerException each time we try to make a connection. The reason we want to connect to it using JDBC is ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Accessing text file via JDBC

  1. Accessing text file via JDBC

    We are trying to access text files using JDBC on a zLinux server. But, somehow we keep on getting a NullPointerException each time we try to make a connection. The reason we want to connect to it using JDBC is because we have a flat file that contains around 4,000 rows and 100 fields per/row and we want to query like a database.





    We are using the driver “jdbcdbcriver={Microsoft Text Driver (*.txt; *.csv)}” for making the connection and it works fine when I try it locally on my Windows machine.



    But when we try the same code on one of the zLinux test servers, it throws the NullPointerException. The text files are on the same machine on which the application is deployed.




    We are making the connection using following code...




    String driver = "jdbcdbcriver={Microsoft Text Driver (*.txt; *.csv)};" + "DBQ=" + path + ";Extensions=asc,csv,tab,txt";



    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");



    conn = DriverManager.getConnection(driver, "", "");




    The last line sets conn to null when we try it on the zLinux box. We have also tried things such as replacing the semicolons in the line above with the system dependant File.separatorChar. We tried going about it differently with this code:


    Driver d = (Driver)( Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance() );

    Properties properties = new Properties();



    System.out.println( "Accepts URL: " + d.acceptsURL(driver) );



    properties.setProperty(" user" , "");



    properties.setProperty(" password" , "" );



    conn = d.connect( driver , properties );




    This results in us being told that the URL is accepted, but conn is still set to null on the zLinux box (and not on Windows). Please let us know if you have any suggestions.

  2. Re: Accessing text file via JDBC

    Is this a WebSphere question? Does the Microsoft Text Driver actually work on a non Microsoft platform? You might want to check on the MSDN website if this actually works on non MS platforms.



    Regards,

    Brian

  3. Re: Accessing text file via JDBC

    Good point - this I actually posted on behalf of a co-worker. It boils down to

    how do you connect to a text file using JDBC via WAS 6.0? Do we need to set up a data source in the WAS 6.0 admin console under the Resources section? In the MS world I know you can do with ADO, and there are helpful sites like www.connectionstrings.com that have info on connecting to just about anything via ADO, but don't know about this in J2EE / WebSphere / JDBC.



    thanks,



    Phil J.

+ Reply to Thread