Use in threaded inet Java applications
Posted by: Elmo Recio
Date: June 07, 2007 08:08PM

I have two threaded classes already. One accepts a request from the net (A), which hands the socket to the processor thread (B) to be placed in a pool. The other threaded class (B) processes the requests from its request pool. When a B-thread wakes up and starts to process the request from the pool, is when it needs to talk to MySQL.

I don't want to create a mysql connection for each thread. I don't want to create a mysql connection for each request coming in. I think that I can prepare/execute a statement and share it among different threads because JDBC will block until I close() the statement.

a) do i have to also close() the connection for the second thread to unblock?
b) How do I share the same mysql connection among the threads in each request processor. Should I declare the mysql connection static and create a static method 'ProcessorThread.connectMysql()' called from the A-thread so that all B-threads could share the connection?
c) do i REALLY have to create a threaded mysql connection manager. I am looking at 20-30 connections per 5 minutes. They are all executing the same query with different params. This is just a "demo" which if it pans out, I can make more robust later.

Options: ReplyQuote


Subject
Written By
Posted
Use in threaded inet Java applications
June 07, 2007 08:08PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.