Connection Pooling In JBOSS
sriramp_here Mar 28, 2005 6:55 AMHi,
I am Using oracle as the datasource. I have a doubt whether I should write any connection pool for the JBoss app Server.Lets Say I have a maximum of
15 connections configured in my oracle-xa-da.xml. I have pasted my oracle-xa-ds below.
<xa-datasource>
<jndi-name>XAOracleDS</jndi-name>
<track-connection-by-tx/>
<isSameRM-override-value>false</isSameRM-override-value>
<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
<xa-datasource-property name="URL">jdbc:oracle:oci8:@tc</xa-datasource-property>
<xa-datasource-property name="User">scott</xa-datasource-property>
<xa-datasource-property name="Password">tiger</xa-datasource-property>
<!-- Uses the pingDatabase method to check a connection is still valid before handing it out from the pool -->
<!--valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name-->
<!-- Checks the Oracle error codes and messages for fatal errors -->
<!-- The minimum connections in a pool/sub-pool. Pools are lazily constructed on first use -->
<min-pool-size>5</min-pool-size>
<!-- The maximum connections in a pool/sub-pool -->
<max-pool-size>20</max-pool-size>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
<!-- Oracles XA datasource cannot reuse a connection outside a transaction once enlisted in a global transaction and vice-versa -->
<no-tx-separate-pools/>
</xa-datasource>
<depends optional-attribute-name="TransactionManagerService">jboss:service=TransactionManager
I have written a connection pool class as shown below.
import java.sql.*;
import javax.sql.*;
import javax.naming.*;
public class DBConnector {
public Connection getConnection(){
try {
Context ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup("java:/DevelopmentDS");
return ds.getConnection();
}catch(Exception exe){
System.out.println ("The exception is " + exe);
return null;
}
}
public void closeConnection (PreparedStatement stmt, ResultSet rs, Connection con){
try{
if (stmt != null){
stmt.close();
}
if (rs != null){
rs.close();
}
if (con != null){
con.close();
}
}catch(Exception exe){
}
}
}
If 25 different Session Beans tries to get the connection from the pool
what will happen, will JBoss internally Queue the Bean until they get a connection. Please help me
Regards
Sriram.P