I'm using a singleton static connection (this is not JDBC) to connect my Java web application to a SAS server. According to my understanding Tomcat creates thread safe objects of each concurrent request hands them over to threads from a thread pool to fulfil. My question is how will my DB connection behave in this setup? Since this is a non-JDBC connection, Tomcat does not have a DB connection pool to work with.
Asked
Active
Viewed 94 times
1 Answers
0
If you are using a singleton class to handle your DB connection, then it will be thread safe by it's nature. Tomcat offers a thread safe implementation for the web application requests. In your implementation, Tomcat threads will use your singleton class for communicating with the DB.
I would also recommend to read more about managing DB connection pools using singleton: https://codereview.stackexchange.com/questions/126621/simple-singleton-database-connection-pool http://rdeshapriya.com/a-singleton-java-class-for-mysql-db-connection/ If I use a singleton class for a database connection, can one user close the connection for everybody?

Adi Ohana
- 927
- 2
- 13
- 18