With regards to servlets being multithreaded by default, does each servlet instantiate a database connection or is the connection shared between all threads of that servlet?
I am using JDBC as an interface between my servlet and an Oracle database.
If a database connection is shared between all threads, does this mean that I should use connection pooling to the database?
/** Open the connection here **/
public void init() {
String url = "server";
String username = "pwd";
String password = "usr";
try {
Class.forName("oracle.jdbc.OracleDriver");
conn = DriverManager.getConnection(url, username, password);
} catch (Exception e) {
System.err.println("Error making pool: " + e);
conn = null;
}
}