• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem in accessing text file using JDBC on zLinux server.

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 �jdbc:odbc:Driver={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 = "jdbc:odbc:Driver={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).

Are we using the wrong driver? Is there any other driver which can be used to connect to text file using JDBC on a zLinux server?

Thanks for your replies.
 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Microsoft Text Driver is for Windows, not for Linux.

>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.
You can try free jdbc driver at http://csvjdbc.sourceforge.net/. If you need to read large file quickly, you can try commercial jdbc drive at http://www.hxtt.com/text.html .
 
reply
    Bookmark Topic Watch Topic
  • New Topic