Hi,
I want to know how to use multithreading in
JDBC? I am in the middle of developing a multithreaded program to read data from ms-access and dump into db2 tables after some calculation. I am calling this tool as data migration tool.
Each ms-access mdb is a fund database (contains atleast 50,000 rows). user can enter any number of funds in the text field(front end GUI) and click submit, and my
java program iterates fund number of times and creates a
thread which actually copies data from MDBs to db2 table. multiple MDBs on ms-access and only one table on DB2.
some thing like:
for(i=0; i<n; i++) //n=50 for 50 funds entered from GUI.
{
Runnable rr = new MyClass(fundid);
Thread t1 = new Thread(rr);
t1.start();
}
run()
{
//open connection to ms-access
//open connection to db2
//read data from ms-access and store in ArrayList
//And copy data from ArrayList(after calculation) to db2 table.
}
if user enters 50 funds like ('TH32','2201','2202'......) in the text field, my program iterates 50 times creating 50 threads. And the program is running slow, not to the desired speed.
Is the logic used correct for multithreading in JDBC. Can I create as many threads as the number of funds?
More over the set up is some thing like this:
My program runs on windows server where mdb files are present and dumps to a database (db2) table which resides on a LINUX machine in the network.
Any help highly appreciated.
Thanks,
Sreedhar.