vishal shah

Greenhorn
+ Follow
since Feb 25, 2008
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by vishal shah

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.
Hi Jeanne,

Thanks for your reply. The reason I am doing it is I have a database containing records of say, 1000 agents. Every month I recieve a new file containing updated counts for the agent. In this case I have to check if I have the agent already in my database or not. If the record does not exist, then I have to insert a record with the new values, else I have to update the existing record by adding the new values to the existing value. If there is no way of filtering a recordset of 1000 agents, then I will have to execute the select and update or insert query for each agent 1000 times:(. And also, this agent count could increase to 10000 in future!

I was thinking that I could create a recordset with all the existing records and then use the Resultset.updateRow() or Resultset.insertRow() method to update or insert which ever row I want. But the only problem is how do I get to that specific record without looping through the resultset.

Thanks,
Vishal
Hi,

Is there any method through which we can jump to a specific record in a java.sql.Resultset (e.g. where the field name matches 'Vishal')?

Thanks,
Vishal