aspose file tools*
The moose likes JDBC and the fly likes Multhreading In JDBC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Multhreading In JDBC" Watch "Multhreading In JDBC" New topic
Author

Multhreading In JDBC

sreekanth chahanapally
Greenhorn

Joined: Jul 02, 2005
Posts: 2
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.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

"sreedhar sreedhar",
dirstly your display name is not valid.

We require display names to be two words: your first name, a space, then your last name. Fictitious names are not allowed.

Please edit your profile and select a valid display name.

thanks,
Dave
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

You haven't really given us enough information to answer your question, but my best guess is:

JDBC is multi-threaded, but in your case it probably is not. If you are using the JDBC-ODBC bridge to connect to Access you cannot do this with multiple threads. See http://java.sun.com/products/jdbc/reference/faqs/index.html#14

Dave
sreekanth chahanapally
Greenhorn

Joined: Jul 02, 2005
Posts: 2
Thanks for the reply. I went thru the link you have sent for no multi-threading in JDBC-OCBC bridge.

You mean each thread executes sequentially? Like, a new thread connecting to an mdb and reading data will occur only when the previous thread finishes reading data from the mdb? Is that correct?

And how about data which is read and stored in the ArrayList and trying to copy this data into db2 using type4 jdbc driver. Does this executes concurrently?

Let me know what more info I can provide to be myself more clear.

Thanks,
 
jQuery in Action, 2nd edition
 
subject: Multhreading In JDBC