[EMAIL PROTECTED] wrote:

Hi all, i'm planning on using servlets for an application I am building.... What I need to know is if there are any thread safe JDBC drivers?
MySQL Connector/J is thread-safe, but even though the JDBC spec states that the driver itself must be thread-safe, most of the API can not be used in a threaded manner.


ie, can I open just one connection to the database for a multithreaded servlet? Will the mysql JDBC driver serialize access or allow concurrent statements? Or will I have to worry about synchronization?
The driver will serialize access, but you most likely will not want to do that. You will get lower through-put than with multiple connections, and since transactions are mapped to connections, if you ever want to use transactions, you will need to devote one connection per client.

You can do this efficiently by using a connection pool, which should be provided by your servlet container.

The JDBC API was not really designed to be used in a multi-threaded fashion, so I would avoid it if you can.


-Mark


--
For technical support contracts, visit https://order.mysql.com/?ref=mmma

__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Mark Matthews <[EMAIL PROTECTED]>
/ /|_/ / // /\ \/ /_/ / /__ MySQL AB, Full-Time Developer - JDBC/Java
/_/ /_/\_, /___/\___\_\___/ Flossmoor (Chicago), IL USA
<___/ www.mysql.com


---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



Reply via email to