• 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

Multhreading In JDBC

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"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
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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,
 
reply
    Bookmark Topic Watch Topic
  • New Topic