I am trying to understand connection pooling in java
, i am using jsp, servlet and tomcat 6 server
in my application. I have written the following code in a java class dbconnection.java
:
I am using type 4 jdbc connection with oracle 10g EE in windows Xp OS
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class dbconnection {
public Connection con = null;
public Connection getConnection() throws Exception, SQLException
{
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:abc","abc", "abc");
}
catch(Exception e)
{
}
return con;
}
public void removeConnection() throws SQLException
{
con.close();
}
}
Then i am retriving connection
in servlet as follows:
try{
dbconnection db= new dbconnection();
Connection con=db.getConnection();
}
catch(Exception e){
}
finally{
db.removeConnection();//removes connection
}
Is it connection pooling
or some configuration is required in tomcat server
or something else?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…