Two Laptop Bag*
The moose likes Java in General and the fly likes Loading file data into a DB2 table using java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Loading file data into a DB2 table using java" Watch "Loading file data into a DB2 table using java" New topic
Author

Loading file data into a DB2 table using java

sanjeev askjeev
Greenhorn

Joined: Oct 12, 2005
Posts: 5
Loading file data into a DB2 table using java. How to achieve this.
Any code snippet will be more helpful.
Thanks
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

JDBC.
Aviroop Ghosh
Greenhorn

Joined: May 17, 2005
Posts: 4
Look in any Java code that uses JDBC to access any database. The key for you would be to trace out the connection strings and the Driver class and names correctly.
You could take a look at the following article. See if this helps you in any way
Hooking up DB2 from Java
Edward Harned
Ranch Hand

Joined: Sep 19, 2005
Posts: 291

java.sql.DriverManager.registerDriver((Driver)
Class.forName
("name of driver").newInstance());

Connection con = DriverManager.getConnection( Your URL );

Statement stmt = con.createStatement();


Ed's latest article: A Java Parallel Calamity http://coopsoft.com/ar/Calamity2Article.html
jiju ka
Ranch Hand

Joined: Oct 12, 2004
Posts: 306
Seems like a batch job. Use prepared statements for better performance.

Don't read full flat file at a stretch. Instead read only sufficient information to create a record in db2.

Depending on the problem you can maintain transaction level at record level or file level. For record level after each record insert you need to commit. Else a single commit after every records are inserted.
sanjeev askjeev
Greenhorn

Joined: Oct 12, 2005
Posts: 5
thanks for the responses. there is a LOAD utility in db2 n just figured out that only i can use it directly in a statement would be have a stored procedure.
The other way could be read file line by line calling Insert stmts at every iteration.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Loading file data into a DB2 table using java
 
Similar Threads
How to read/write text file to db2 by using java code
Data Retrival in Clustered environment
it takes longer time to show the report for the first time
Limit in sending input data to db2 stored procedure
Inserts using java or plsql