Connection pooling works finally right

I solved the wait problem for a free connection with an event-emitter
now I can have as few connections in the pool as I want and as many concurrent
requests as I want
the requests for a free connection are queued in the event-loop of node
so 5 connections and 100 concurrent requests are no problem
my code:
//prepare the event
var EventEmitter = require('events').EventEmitter;
var util = require('util');
var MyEvent = function(  ) {
util.inherits( MyEvent,EventEmitter );
MyEvent.prototype.FreeCon = function () {
this.emit( 'connectionfree' );
var myConEvent = new MyEvent();
//at connection release:
connection.release(
function(err)
if (err) {
console.error('release() callback: ' + err.message);
return;
myConEvent.FreeCon ();
// sleeping  for a free connection:
oracledb.pooler.getConnection (
function(err, connection)
if (err) {
console.log( anzahl+ '  '+oracledb.pooler.connectionsOpen );
anzahl++;
myConEvent.once( 'connectionfree' , function() {
anzahl--;
getconnection_i( callback );
} else {
callback(connection);      

I am new to node and finally figured out how to solve such load problems
I use a test client and give it some 100k data with 10 or 100 parallel
then I can set the number of connections on my test-server
The test clients has the same problem which I solved with event, to limit the concurrency
the next step is perhaps to use some async for limiting concurrency
I am only learning
the oracle driver dumped because I did not some stuff incorrectly but this was my fault
my biggest problems:
- how to generate (complicated) json in oracle ( I use listagg but it is limited to 4k in 11 )
- clob limit of 32k for procedure input ( or 4k in oracle 11 ? )
- returning clause missing for insert statement ( instead of procedure call )

Similar Messages

  • Error While reading CLOB from Oracle using WebLogic Connection Pool, Works fine with out using pool

    PROBLEM DESCRIPTION :
         When I try to read a clob from Oracle, I receive "ORA-03120: two-task
    conversion routine: integer overflow" Error.
         This error occurs only for CLOB Type and only if I try to connect to
    Oracle using WebLogic JDriver/Oracle POOL.
         IMPORTANT NOTE: I can read CLOB or any other data using direct JDBC
    connection to ORacle with out any problem.
         Below Please find the JAVA CODE for Both Working and NON Working .
    Created a Connection Pool as:
    Name: MyJDBCConnectionPool
    URL : jdbc:weblogic:oracle
    DIRVER:weblogic.jdbc.oci.Driver
    NON WORKING JAVA CODE (USES WEBLOGIC JDBC CONNECTION POOL TO ORACLE):
    Driver myDriver =
    (Driver)Class.forName("weblogic.jdbc.pool.Driver").newInstance();
    Connection mconn =
    myDriver.connect("jdbc:weblogic:pool:MyJDBCConnectionPool",null);
    mconn.setAutoCommit (false);
    CallableStatement cs = mconn.prepareCall("{call
    P_XMLTEST2(?)}"); //This returns a CLOB
    cs.registerOutParameter(1,java.sql.Types.CLOB);
    cs.execute();
    Clob clob = null;
    clob = cs.getClob(1);
    String data =new String();
    data = clob.getSubString(1, (int)clob.length());
    System.out.println(data); //print the data
    data = null;
    clob=null;
    cs.close();
    WORKING JAVA CODE (USES DIRECT THIN JDBC CONNECTION TO ORACLE):
    Driver myDriver =
    (Driver)Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
    Connection mconn =
    myDriver.connect("jdbc:oracle:thin:@server:1521:DB",null);
    mconn.setAutoCommit (false);
    CallableStatement cs = mconn.prepareCall("{call
    P_XMLTEST2(?)}"); //This returns a CLOB
    cs.registerOutParameter(1,java.sql.Types.CLOB);
    cs.execute();
    Clob clob = null;
    clob = cs.getClob(1);
    String data =new String();
    data = clob.getSubString(1, (int)clob.length());
    System.out.println(data); //print the data
    data = null;
    clob=null;
    cs.close();
    ERROR MESSAGE:
         ORA-03120: two-task conversion routine: integer overflow
    I appreciate your help on this problem.

    PROBLEM DESCRIPTION :
         When I try to read a clob from Oracle, I receive "ORA-03120: two-task
    conversion routine: integer overflow" Error.
         This error occurs only for CLOB Type and only if I try to connect to
    Oracle using WebLogic JDriver/Oracle POOL.
         IMPORTANT NOTE: I can read CLOB or any other data using direct JDBC
    connection to ORacle with out any problem.
         Below Please find the JAVA CODE for Both Working and NON Working .
    Created a Connection Pool as:
    Name: MyJDBCConnectionPool
    URL : jdbc:weblogic:oracle
    DIRVER:weblogic.jdbc.oci.Driver
    NON WORKING JAVA CODE (USES WEBLOGIC JDBC CONNECTION POOL TO ORACLE):
    Driver myDriver =
    (Driver)Class.forName("weblogic.jdbc.pool.Driver").newInstance();
    Connection mconn =
    myDriver.connect("jdbc:weblogic:pool:MyJDBCConnectionPool",null);
    mconn.setAutoCommit (false);
    CallableStatement cs = mconn.prepareCall("{call
    P_XMLTEST2(?)}"); //This returns a CLOB
    cs.registerOutParameter(1,java.sql.Types.CLOB);
    cs.execute();
    Clob clob = null;
    clob = cs.getClob(1);
    String data =new String();
    data = clob.getSubString(1, (int)clob.length());
    System.out.println(data); //print the data
    data = null;
    clob=null;
    cs.close();
    WORKING JAVA CODE (USES DIRECT THIN JDBC CONNECTION TO ORACLE):
    Driver myDriver =
    (Driver)Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
    Connection mconn =
    myDriver.connect("jdbc:oracle:thin:@server:1521:DB",null);
    mconn.setAutoCommit (false);
    CallableStatement cs = mconn.prepareCall("{call
    P_XMLTEST2(?)}"); //This returns a CLOB
    cs.registerOutParameter(1,java.sql.Types.CLOB);
    cs.execute();
    Clob clob = null;
    clob = cs.getClob(1);
    String data =new String();
    data = clob.getSubString(1, (int)clob.length());
    System.out.println(data); //print the data
    data = null;
    clob=null;
    cs.close();
    ERROR MESSAGE:
         ORA-03120: two-task conversion routine: integer overflow
    I appreciate your help on this problem.

  • How database connection pooling works in a application

    Hi Guys,
    I am new to Java and looking into best way of doing J2ee database conectivity. I am using Eclipse galileo3.5 J2EE with Mysql database and Tomcate 6.0.
    I am developing an email application where I need to implement MVC model for my webapplication, using jsp for presentation, servlet for control and java beans for model.
    I came across two tutorial for database connection pooling as given below.
    Eclipse Corner Article: Creating Database Web Applications with Eclipse - In this tutorial connection pooling is configure in Tomcate 6.0
    It says Copy and paste the following into your context.xml file (you may have to click on the Source tab at the bottom of the editor to be able to paste). This defines a DataSource with the name "jdbc/SampleDB". Our application will retrieve database connections from the pool using this name.
    <?xml version="1.0" encoding="UTF-8"?>
    <Context>
    <Resource name="jdbc/SampleDB" auth="Container"
    type="javax.sql.DataSource"
    username="app" password="app"
    driverClassName="org.apache.derby.jdbc.ClientDrive r"
    url="jdbc:derby://localhost:1527/sample"
    maxActive="8" />
    </Context>
    Where as in second tutorial - http://www.roseindia.net/answers/viewanswers/2838.html
    It uses java bean for connection pooling and then use straight way in JSP and no Servlet used.
    conpool.jsp
    <%@page import="java.sql.Connection"%>
    <jsp:useBean id="pl" class="com.CoreJava.ConnectionPooling"/>
    <% Connection con = pl.getConnection(); %>
    //do something using con
    connectionPooling.java
    import com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolD ataSource;
    public class ConnectionPooling
    static Connection con=null;
    public static Connection getConnection()
    try
    MysqlConnectionPoolDataSource po=new MysqlConnectionPoolDataSource();
    po.setServerName("localhost");
    po.setPortNumber(3306);
    po.setDatabaseName("mydatabase"); //changeur database name
    po.setUser("root");//ur username
    po.setPassword("");//ur password
    con = po.getConnection();
    catch(Exception e)
    System.out.println("Exception Connection :"+e);
    return con;
    Please some one explain which is the best way of doing connection pooling to the database by using MVC pattern
    Please if some one advise me how to use MVC architecture for simple email application and database connectivty.
    Thanks

    >
    >
    Where as in second tutorial - http://www.roseindia.net/answers/viewanswers/2838.html
    Never EVER use roseindia. It is terrible shit.
    [http://balusc.blogspot.com/2008/06/what-is-it-with-roseindia.html]
    The correct answer is what you found in the eclipse article. And you can read the Tomcat docs for more.
    As per usual the code you have posted from Roseindia is a big pile of rubbish that was written by a complete idiot. I mean the person who wrote it apparently doesn't know much Java at all. Let alone JDBC. Or Connection pools. Or J2EE. It's not the worst I've seen from them but it's pretty bad.

  • BC4J Question: How does AM and Connection Pooling work?

    Hello everybody,
    we are just trying to understand what exactly happens when a BC4J Application Module is created / when a AM is checked out of the pool with respect to Connection and Application Module Pooling. Especially we would like to understand what ConnectionStartegies, EnvInfoProvider and SessionCookies exactly do and when and how to customize them. Especially we would like to use features like virtual private databases (VPD) and proxy authentication (a feature of the Oracle OCI JDBC driver) with BC4J application modules. We found the HowTo about using JAAS and VPDs with BC4J (http://otn.oracle.com/products/jdev/howtos/bc4j/bc4jvpdjaas.html) but there are still questions, e.g. when is the afterConnect() method of an ApplicationModuleImpl called? During the instanciation of an AM or every time it's check out of the pool?
    Any info on this topic would be very welcome!
    Regards
    Stefan

    Hi,
    1. Setting jbo.doconnectionpooling=false ,
    connection pool still exists.
    Is it correct ? When you set this parameter to false, you are saying that Connection Pool is not managed by AM, so you need to specify a JNDI Name in Application Module to use a Pool not managed by AM.
    2. There is one situation to set
    jbo.doconnectionpooling=true. The article said
    "when you have a large number of application
    module pools all needing to database connections
    from the same underlying application user at the
    database level. In this case, the many application
    module pools can perhaps economize on the total
    overall database sessions by sharing a single,
    underlying database connection pool of JDBC
    connections, albeit at a loss of efficiency of each
    one. This choice would be favored only if total
    overall database sessions is of maximum priority. "
    Does it mean that if we set it to true when we
    have many many AM instances and we cannot afford to
    have such number of connection instance in the pool
    ? It's means that the JDBC connections will be shared avoid new Connection at time.
    Normally i use Connection Pool not managed by Application Module.
    Bye

  • Threading with connection pool

    Hi
    My application is an interface to ldap directory. I have not used any ldap open source api to retrieve data from ldap. I have written connection pool that will help the application to connect to the ldap. It's working fine, but it's creating threads which are not invited.
    ConnectionPool class takes care of the connection storage and creation, while Housekeeping thread relases these connection when idle after a given time.
    Can someone please help in finding the problem in the code that creates additional threads.
    package com.ba.cdLookup.manager;
    import com.ba.cdLookup.exception.CDLookupException;
    import com.ba.cdLookup.server.CdLookupProperties;
    import java.util.Vector;
    import javax.naming.Context;
    import javax.naming.NamingException;
    public class HouseKeeperThread extends Thread {
             * Apache Logger to log erro/info/debug statements.
        protected static org.apache.commons.logging.Log log = org.apache.axis.components.logger.LogFactory
             .getLog(HouseKeeperThread.class.getName());
        private static HouseKeeperThread houseKeeperThread;
             * Close all connections existing.
             * @param connections
             *                void
        private void closeConnections(Vector connections) {
         String methodIdentifier = "closeConnections";
         int numOfConn = connections.size();
         try {
             for (int i = 0; i < numOfConn; i++) {
              Context context = (Context) connections.get(i);
              if (context != null) {
                  context.close();
                  context = null;
                  connections.remove(i);
                  numOfConn--;
                  log.info(" connection name:" + context
                       + " removed. Threadcount =" + (connections.size()));
         } catch (NamingException e) {
             String errMsg = "CDLdapBuilder connect() - failure while releasing connection "
                  + " Exception is " + e.toString();
             log.error(errMsg);
         } catch (Exception e) {
             String errMsg = "CDLdapBuilder connect() - failure while releasing connection "
                  + " Exception is " + e.toString();
             log.error(errMsg);
             * Thread run method
        public void run() {
         String methodIdentifier = "run";
         try {
             while(true){
              log.debug("house keeping :" + this + " ---sleep");
              //sleep(100000);
              log.debug("house keeping :" + this + " startd after sleep");
               sleep(CdLookupProperties.getHouseKeepConnectionTime());
              ConnectionPool connectionPool = ConnectionPool
                   .getConnectionPool();
              Vector connList = connectionPool.getAvailableConnections();
              closeConnections(connList);
         } catch (CDLookupException cde) {
             log.error(methodIdentifier + " " + cde.getStackTrace());
         } catch (InterruptedException ie) {
             log.error(methodIdentifier + " " + ie.getStackTrace());
         * @param connectionPool
         * @return
         * Thread
        public static Thread getInstance() {
         if(houseKeeperThread==null){
             houseKeeperThread = new HouseKeeperThread();
         return houseKeeperThread ;
    package com.ba.cdLookup.manager;
    import com.ba.cdLookup.exception.CDLookupException;
    import com.ba.cdLookup.server.CdLookupProperties;
    import com.ba.cdwebservice.schema.cdLookupPacket.LookupFailureReasons;
    import java.util.Properties;
    import java.util.Vector;
    import javax.naming.Context;
    import javax.naming.NamingException;
    import javax.naming.directory.DirContext;
    import javax.naming.directory.InitialDirContext;
    * ConnectionPool class manages, allocates LDAP connections. It works as a lazy
    * binder and retrieves connections only when required. It doesn't allow
    * connection greater then the maximum connection stated.
    * To retrieve a connection the singelton method getConnectionPool is to used,
    * which retruns thread safe singleton object for the connection.
    public class ConnectionPool implements Runnable {
        private int initialConnections = 0;
        private int maxConnections = 0;
        private boolean waitIfBusy = false;
        private Vector availableConnections, busyConnections;
        private boolean connectionPending = false;
        private static int threadCount = 0;
             * classIdentifier
        private final String classIdentifier = "ConnectionPool";
             * Apache Logger to log erro/info/debug statements.
        protected static org.apache.commons.logging.Log log = org.apache.axis.components.logger.LogFactory
             .getLog(CDLdapBuilder.class.getName());
             * To get the attribute a systemaccessfor out of the search result
        private String vendorContextFactoryClass = "com.sun.jndi.ldap.LdapCtxFactory";// "com.ibm.jndi.LDAPCtxFactory";
             * context factory to use
        private String ldapServerUrl = "LDAP://test.ldap.com"; // default ldap
             * server live used by default
        private String searchBase;
             * environment properties.
        private Properties env;
             * DirContext
        private javax.naming.directory.DirContext ctx;
             * default search base to be used in Corporate Directory searches
        private String defaultSearchBase = "dc=Pathway";
             * search criteria
        private String searchAttributes;
             * search filter to retrieve data from CD
        private String searchFilter;
             * CorporateDirectoryLookup Constructor
             * <p>
             * loads the setup parameters from the properties file and stores them
             * Makes a connection to the directory and sets default search base
             * @throws CDLookupException
             * @throws CDLookupException
        private ConnectionPool() throws CDLookupException {
         this.maxConnections = CdLookupProperties.getMaxConnection();// maxConnections;
         this.initialConnections = CdLookupProperties.getInitialConnection();
         this.waitIfBusy = CdLookupProperties.isWaitIfBusy();
         this.searchBase = CdLookupProperties.getDefaultSearchBase();
         //for local env testing
    //      this.maxConnections = 5;
    //      this.initialConnections = 1;
    //      this.waitIfBusy = true;
             * For keeping no of connections in the connection pool if
             * (initialConnections > maxConnections) { initialConnections =
             * maxConnections; }
         availableConnections = new Vector(maxConnections);
         busyConnections = new Vector(maxConnections);
         for (int i = 0; i < maxConnections; i++) {
             availableConnections.add(makeNewConnection());
             *  ConnectionPoolHolder provide Thread safe singleton
             *         instance of ConnectionPool class
        private static class ConnectionPoolHolder {
             * connection pool instance
         private static ConnectionPool connectionPool = null;
             * If no ConnectionPool object is present, it creates instance of
             * ConnectionPool class and initiates thread on that.
             * @return ConnectionPool Returns singleton object of ConnectionPool
             *         class.
             * @throws CDLookupException
         private static ConnectionPool getInstance() throws CDLookupException {
             if (connectionPool == null) {
              connectionPool = new ConnectionPool();
              new Thread(connectionPool).start();
              // Initiate house keeping thread.
              HouseKeeperThread.getInstance().start();
             return connectionPool;
             * Returns singleton object of ConnectionPool class.
             * @return ConnectionPool
             * @throws CDLookupException
        public static ConnectionPool getConnectionPool() throws CDLookupException {
         return ConnectionPoolHolder.getInstance();
             * getConnection retrieves connections to the corp directory. In case
             * there is no available connections in the pool then it'll try to
             * create one, if the max connection limit for the connection pool
             * reaches then this waits to retrieve one.
             * @return Context
             * @throws CDLookupException
        public synchronized Context getConnection() throws CDLookupException {
         String methodIdentifier = "getConnection";
         if (!availableConnections.isEmpty()) {
             int connectionSize = availableConnections.size() - 1;
             DirContext existingConnection = (DirContext) availableConnections
                  .get(connectionSize);
             availableConnections.remove(connectionSize);
                     * If connection on available list is closed (e.g., it timed
                     * out), then remove it from available list and repeat the
                     * process of obtaining a connection. Also wake up threads that
                     * were waiting for a connection because maxConnection limit was
                     * reached.
             if (existingConnection == null) {
              notifyAll(); // Freed up a spot for anybody waiting
              return (getConnection());
             } else {
              busyConnections.add(existingConnection);
              return (existingConnection);
         } else {
                     * Three possible cases: 1) You haven't reached maxConnections
                     * limit. So establish one in the background if there isn't
                     * already one pending, then wait for the next available
                     * connection (whether or not it was the newly established one).
                     * 2) You reached maxConnections limit and waitIfBusy flag is
                     * false. Throw SQLException in such a case. 3) You reached
                     * maxConnections limit and waitIfBusy flag is true. Then do the
                     * same thing as in second part of step 1: wait for next
                     * available connection.
             if ((totalConnections() < maxConnections) && !connectionPending) {
              makeBackgroundConnection();
             } else if (!waitIfBusy) {
              throw new CDLookupException("Connection limit reached", 0);
                     * Wait for either a new connection to be established (if you
                     * called makeBackgroundConnection) or for an existing
                     * connection to be freed up.
             try {
              wait();
             } catch (InterruptedException ie) {
              String errMsg = "Exception raised =" + ie.getStackTrace();
              log.error(errMsg);
              throw new CDLookupException(classIdentifier, methodIdentifier,
                   errMsg, ie);
             // connection freed up, so try again.
             return (getConnection());
             * You can't just make a new connection in the foreground when none are
             * available, since this can take several seconds with a slow network
             * connection. Instead, start a thread that establishes a new
             * connection, then wait. You get woken up either when the new
             * connection is established or if someone finishes with an existing
             * connection.
        private void makeBackgroundConnection() {
         connectionPending = true;
         try {
             Thread connectThread = new Thread(this);
             log.debug("background thread created");
             connectThread.start();
         } catch (OutOfMemoryError oome) {
             log.error("makeBackgroundConnection ="+ oome.getStackTrace());
             * Thread run method
        public void run() {
         String methodIdentifier = "run";
         try {
             Context connection = makeNewConnection();
             synchronized (this) {
              availableConnections.add(connection);
              connectionPending = false;
              notifyAll();
         } catch (Exception e) { // SQLException or OutOfMemory
             // Give up on new connection and wait for existing one
             // to free up.
             String errMsg = "Exception raised =" + e.getStackTrace();
             log.error(errMsg);   
             * This explicitly makes a new connection. Called in the foreground when
             * initializing the ConnectionPool, and called in the background when
             * running.
             * @return Context
             * @throws CDLookupException
        private Context makeNewConnection() throws CDLookupException {
         String methodIdentifier = "makeNewConnection";
         Context context = null;
         env = new Properties();
         log.debug("inside " + methodIdentifier);
         try {
             env.put(Context.INITIAL_CONTEXT_FACTORY,
                  getVendorContextFactoryClass());
             env.put(Context.PROVIDER_URL, getLdapServerUrl());
             env.put("com.sun.jndi.ldap.connect.pool", "true");
             context = new InitialDirContext(env);
         } catch (NamingException e) {
             String errMsg = "CDLdapBuilder connect() - failure while attempting to contact "
                  + ldapServerUrl + " Exception is " + e.toString();
             throw new CDLookupException(classIdentifier, methodIdentifier,
                  errMsg, e, LookupFailureReasons.serviceUnavailable);
         } catch (Exception e) {
             String errMsg = "CDLdapBuilder connect() - failure while attempting to contact "
                  + ldapServerUrl + " Exception is " + e.toString();
             throw new CDLookupException(classIdentifier, methodIdentifier,
                  errMsg, e, LookupFailureReasons.serviceUnavailable);
         log.info("new connection :" + (threadCount++) + " name =" + context);
         log.debug("exit " + methodIdentifier);
         return context;
             * releases connection to the free pool
             * @param context
        public synchronized void free(Context context) {
         busyConnections.remove(context);
         availableConnections.add(context);
         // Wake up threads that are waiting for a connection
         notifyAll();
             * @return int give total no of avail connections.
        public synchronized int totalConnections() {
         return (availableConnections.size() + busyConnections.size());
             * Close all the connections. Use with caution: be sure no connections
             * are in use before calling. Note that you are not <I>required</I> to
             * call this when done with a ConnectionPool, since connections are
             * guaranteed to be closed when garbage collected. But this method gives
             * more control regarding when the connections are closed.
        public synchronized void closeAllConnections() {
         closeConnections(availableConnections);
         availableConnections = new Vector();
         closeConnections(busyConnections);
         busyConnections = new Vector();
             * Close all connections existing.
             * @param connections
             *                void
        private void closeConnections(Vector connections) {
         String methodIdentifier = "closeConnections";
         try {
             for (int i = 0; i < connections.size(); i++) {
              Context context = (Context) connections.get(i);
              if (context != null) {
                  log.info(" connection name:" + context
                       + " removed. Threadcount =" + (threadCount++));
                  context.close();
                  context = null;
         } catch (NamingException e) {
             String errMsg = "CDLdapBuilder connect() - failure while attempting to contact "
                  + ldapServerUrl + " Exception is " + e.toString();
             log.error(errMsg);
        public synchronized String toString() {
         String info = "ConnectionPool(" + getLdapServerUrl() + ","
              + getVendorContextFactoryClass() + ")" + ", available="
              + availableConnections.size() + ", busy="
              + busyConnections.size() + ", max=" + maxConnections;
         return (info);
             * @return the defaultSearchBase
        public final String getDefaultSearchBase() {
         return defaultSearchBase;
             * @param defaultSearchBase
             *                the defaultSearchBase to set
        public final void setDefaultSearchBase(String defaultSearchBase) {
         this.defaultSearchBase = defaultSearchBase;
             * @return the ldapServerUrl
        public final String getLdapServerUrl() {
         return ldapServerUrl;
             * @param ldapServerUrl
             *                the ldapServerUrl to set
        public final void setLdapServerUrl(String ldapServerUrl) {
         this.ldapServerUrl = ldapServerUrl;
             * @return the vendorContextFactoryClass
        public final String getVendorContextFactoryClass() {
         return vendorContextFactoryClass;
             * @param vendorContextFactoryClass
             *                the vendorContextFactoryClass to set
        public final void setVendorContextFactoryClass(
             String vendorContextFactoryClass) {
         this.vendorContextFactoryClass = vendorContextFactoryClass;
         * @return the availableConnections
        public final Vector getAvailableConnections() {
            return availableConnections;
    }

    hi ejp
    Thx for the reply.
    // Enable connection pooling
    env.put("com.sun.jndi.ldap.connect.pool", "true");
    Is this suffice to get the connection pool working,
    Should i merely have a thread to maintain the connection with the ldap that uses sun's connection pool; or allow requestes to create new object for the connection and still this pool will hold.
    for example in the above code instead to housekeep the thread merely maintain connection with the pool
    or
    should I directly connect each object with the ldap?
    I am unable to understand how exactly sun's connection pool is working and how it should be used. I have gone thru the following example but picture is still hazy and undigestable to me.
    java.sun.com/products/jndi/tutorial/ldap/connect/pool.html
    Rgds

  • Mvc - connection pool - jstl - oh my!

    I am trying to understand how to use the mvc model to break my existing jsp's up. I finally got my connection pool working yesterday(yay!) so now I want to get everything organized into servlets. My understanding of servlets sucks - and I have not written one yet. Researching it on the net hasnt helped much - a bit overwhelming..
    Please tell me if my logic is on track or not - keeping in mind the mvc model - keeping in mind I dont know how to write a servlet : )
    DATABASE package;
    public static dbpool getConnection() {
         // write JNDI information
    public static void dbpoolClose(Connection connDB) {
         // close connection
    }Then in a servlet I would try to write something like this...
    MyBean {
    // call the connection method
    - do crud operations
    - use getters and setters
    - close statements that I have open
    // call the close connection method
    }Then in my JSP( I have JSTL working YAY!!) I wil call the bean/getters/setters and use JSTL to manipulate and present the data? Is this close to being in the MVC model?
    I havent found an example using the mvc using a connection pool, database operations and a jsp - that I have been able to understand.. so If I am waay off.. sorry.

    Basically, use the servlet to tell other classes what to do (these can be other servlets or whatever).
    Those classes prepare the data you want to have the JSPs show and process the data returned from the JSPs.
    The JSP does nothing except display data presented to it by the servlet (and may have URLs or forms to provide input to servlets.
    At its simplest, there's no controller at all (so no C). A JSP calls a servlet which processes the data sent to it and prepares new data for another (or the same) JSP to which it forwards the request when done.
    That data can be stored in the Http session or (sometimes) better in the request.
    More usually, a controller will receive all requests from and determine to what servlet to send them.
    The servlet then either determines on its own to which JSP to send the results or gives those results back to the controller which will do that for them and forward to the proper JSP.
    If needed you can thus chain requests so that a request goes to a servlet, from there to another servlet and then to a JSP (for example), each time via the controller.
    This can be handy to break up complex processing in small steps where those small steps could also occur separate.

  • Hi Guys, can you please help me with Connection Pooling.

    I have:-
    Tomcat 5.0.27
    MySQL 4
    Apache 2.0.
    JSP web pages.
    I have been trying to get connection pooling working but i havent been successful yet. Please do help me make it happen.
    I have posted my server.xml and web.xml from /conf/. They are not edited. I have also included the pages that I am currently ussing to connect to the database.
    I need you to assist me with how I should edit the above.
    1.     SERVER.XML
    Where and how should I edit this file?
    2.     WEB.XML
    Where and how should I edit this file?
    3.     DATABASE_INFO.JSP
    <%
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    %>
    <%!
    public java.sql.Connection dataconnect() throws SQLException {
    Connection database_connector;
    database_connector = DriverManager.getConnection("jdbc:mysql://localhost/publications?user=hello&password=hello");
    return database_connector;
    %>
    <%!
    public java.sql.Connection adminconnect(javax.servlet.http.HttpSession session) throws SQLException {
    Connection database_connector;
    if (session.getAttribute("s_conn")!=null) {
    database_connector = (Connection) session.getAttribute("s_conn");
    if (database_connector.isClosed()) {
    database_connector = DriverManager.getConnection("jdbc:mysql://localhost/publications?user=hello&password=hello");
    } else {
    database_connector = DriverManager.getConnection("jdbc:mysql://localhost/publications?user=hello&password=hello");
    session.setAttribute("s_conn", database_connector);
    return database_connector;
    %>
    <%!
    public String filedir() {
    String directory = "C:/Tomcat/webapps/ROOT/publications/";
    return directory;
    %>
    etc
    Database Name : publications

    Hi,
    1- put your jdbc driver jar file in $CATALINA_HOME/common/lib (ex: C:\tomcat\common\lib )
    2- Next, modify the web application deployment descriptor (/WEB-INF/web.xml) to declare the JNDI name under which you will look up preconfigured data source
    take care of the ordering as below so resourc-ref tag is after taglib
    <resource-ref>
    <description>
    Resource reference to a factory for java.sql.Connection
    instances that may be used for talking to a particular
    database that is configured in the server.xml file.
    </description>
    <res-ref-name>
    jdbc/EmployeeDB
    </res-ref-name>
    <res-type>
    javax.sql.DataSource
    </res-type>
    <res-auth>
    Container
    </res-auth>
    </resource-ref>
    3- add an element like this to the /META-INF/context.xml file in the web application. ( under ../webapps/mywebapplication/WEB-INF
    <Context ...>
    <Resource name="jdbc/EmployeeDB" auth="Container"
    type="javax.sql.DataSource" username="hello" password="hello"
    driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost/publications"
    maxActive="8" maxIdle="4"/>
    </Context>
    4- code sample
    Context initCtx = new InitialContext();
    Context envCtx = (Context) initCtx.lookup("java:comp/env");
    DataSource ds = (DataSource)
    envCtx.lookup("jdbc/EmployeeDB");
    Connection conn = ds.getConnection();
    ... use this connection to access the database ...
    conn.close();
    The default data source support in Tomcat is based on the DBCP connection pool from the jakarta commons
    Regards,
    Alan Mehio
    London,UK

  • Using Connection Pooling in a WLS 5.1.x - Cluster

    Hi,
              We have problems using connection pooling in a WLS 5.1.x - Cluster. Is it
              possible to use CP in such a cluster at all ? The problem is, connections
              will be opened and never been closed. How can I configure a cluster for CP?
              I have a WLS-Cluster with 2 instances and my webApp uses connection pooling.
              By the way I get a connection on Instance 1, Instance 2 gets a connection
              also, but never releases it.
              In my opinion, the reference to the connection in the partner-instance will
              be lost.
              How do I have to configure my cluster to work well with that stuff ?
              Thank a lot,
              Markus.
              

    Clustering with connection pools works fine in WLS 5.1. If connections are
              not being release, you have bugs in your code.
              When a connection is retrieved from a pool on one instance, a corresponding
              connection is NOT retrieved on another instance.
              Mike
              "M. Hammer" <[email protected]> wrote in message
              news:[email protected]..
              > Hi,
              >
              > We have problems using connection pooling in a WLS 5.1.x - Cluster. Is it
              > possible to use CP in such a cluster at all ? The problem is, connections
              > will be opened and never been closed. How can I configure a cluster for
              CP?
              >
              > I have a WLS-Cluster with 2 instances and my webApp uses connection
              pooling.
              > By the way I get a connection on Instance 1, Instance 2 gets a connection
              > also, but never releases it.
              > In my opinion, the reference to the connection in the partner-instance
              will
              > be lost.
              > How do I have to configure my cluster to work well with that stuff ?
              >
              > Thank a lot,
              >
              > Markus.
              >
              >
              >
              

  • Failover and Load Balancing with JNDI Connection Pools

    Hi,
    I am trying to figure out how would JNDI Connection Pooling work along with failover or DNS Load Balancing.
    Would connections be distributed equally among the list?
    Would the pool work with multiple heterogeneous connections (i.e. connections to different but equivalent servers ), or do all the connections in the pool have to be homogeneous (i.e. to the same server)?
    Thanks,
    Sergio

    Hi,
    I am trying to figure out how would JNDI Connection Pooling work along with failover or DNS Load Balancing.
    Would connections be distributed equally among the list?
    Would the pool work with multiple heterogeneous connections (i.e. connections to different but equivalent servers ), or do all the connections in the pool have to be homogeneous (i.e. to the same server)?
    Thanks,
    Sergio

  • Configuring JMS Connection Pooling

    Hi there,
              as far as I understand, if I use a resource-ref when declaring a JMS connection factory, pooling connections, sessions, and producers is automatically enabled. Is there any way for fine-tuning the way this pool works, e.g. configuring minimum/maximum pool sizes?
              We are using WLS 9.2 MP 1, using WebSphere MQ as remote JMS provider (with com.ibm.mq.jms.MQXAQueueConnectionFactory as factory implementation).
              Best regards
              Martin

    Hi Tom,
              thanks for your answer. Assuming that the BEA connection pooling works fine, there is still the IBM ConnectionFactory implementation that provides its own connection pooling.
              Do you know a way to configure this part? I only see the Java API of this class when registering it in the JNDI tree, and it provides no access to connection pooling settings.
              Best regards
              Martin

  • Clarification needed on JDBC Connection Pool in  Clustered enviornment

    Hi All,
              Although I went through the bea online documentation , its not clear how
              JDBC connection pool works in clustered environment.
              If anyone can please answer following questions, it would be a great help.
              1) Do I need to create identical connection pools (with identical ACLs) on
              each WebLogic Server in the cluster ?
              2) Online documentation says " If you create an identical JDBC DataSource in
              each clustered WebLogic Server instance and configure those DataSources to
              use different connection pools, the cluster can support load balancing for
              JDBC connections. " what actually this means
              3) What's the use of "JDBC MultiPools " ? Is it same as "JDBC metapool "
              Thanks
              Regards
              Nalika
              

    See comments inline...
              Nalika wrote:
              > Hi All,
              >
              > Although I went through the bea online documentation , its not clear how
              > JDBC connection pool works in clustered environment.
              > If anyone can please answer following questions, it would be a great help.
              >
              > 1) Do I need to create identical connection pools (with identical ACLs) on
              > each WebLogic Server in the cluster ?
              I don't believe that it is strictly necessary to do this but it is certainly the
              most common configuration and probably the preferred one as well. WLS is smart
              enough to automatically use its Type 3 driver to route requests to a connection
              on another server but this type of server-to-server communication can have an
              impact on performance and scalability.
              > 2) Online documentation says " If you create an identical JDBC DataSource in
              > each clustered WebLogic Server instance and configure those DataSources to
              > use different connection pools, the cluster can support load balancing for
              > JDBC connections. " what actually this means
              Don't read too much into this. All that this is saying is that application
              components in each server will "prefer" to use their local DataSource (all other
              things being equal) and since other clustering technology (or things like
              hardware load balancers) are spreading the load across the servers, you will
              also spread the load across the different connection pools.
              > 3) What's the use of "JDBC MultiPools " ? Is it same as "JDBC metapool "
              Yes, these are one and the same.
              Hope this helps,
              Robert
              

  • How Transaction Manager work with Resource Manager, like Connection pool?

    hi,
    I'm using BEA Webloigc8.1 Stateless Session Bean/DAO/Oracle stored proc.
    but I'm not quite clear how Transaction Manager work with Resource Manager, like Connection pool.
    my understanding is that, in a weblogic transaction, a stateless session bean interact with several DAOs, and for each method of DAO a connection is acquired from connection pool. I've heard that the connection will not return to pool until the transaction commits.
    My question is that, does it mean that for a weblogic transaction, multiple connections might be allocated to it? and if multiple connections are allocated, then how many oracle transactions would be started? or multiple connections share the same oracle transaction?
    I didn't feel it make sense to start multiple oracle transactions, cause deadlock might be incurred in a single weblogic transaction.
    any help appreciated!

    Xin Zhuang wrote:
    hi,
    I'm using BEA Webloigc8.1 Stateless Session Bean/DAO/Oracle stored proc.
    but I'm not quite clear how Transaction Manager work with Resource Manager, like Connection pool.
    my understanding is that, in a weblogic transaction, a stateless session bean interact with several DAOs, and for each method of DAO a connection is acquired from connection pool. I've heard that the connection will not return to pool until the transaction commits.
    My question is that, does it mean that for a weblogic transaction, multiple connections might be allocated to it? and if multiple connections are allocated, then how many oracle transactions would be started? or multiple connections share the same oracle transaction?
    I didn't feel it make sense to start multiple oracle transactions, cause deadlock might be incurred in a single weblogic transaction.
    any help appreciated!Hi. If you configure your WLS DataSource to use keep a connection for
    the duration of a tx, it will do that, and in any case there can be
    no deadlock however many connections operate for a given XA transaction.
    Here is the best coding form for DAOs or any other user-written code
    for using WebLogic DataSources. This is important for two reasons:
    1 - Thread-safety is maintained as long as the connection is a
    method-level object.
    2 - It is crucial to notify WebLogic that you are done with a connection
    ASAP, by your calling close() on it. We will then put it back in the
    pool, or keep it under the covers for your next request if it's in a
    transaction etc. The pool is optimized for quick get-use-close scenarios.
    public void one_of_my_main_JDBC_Methods()
    Connection con=null; // Must be a method level object for thread-safety
    // It will be closed by the end of the method.
    try {
    con = myDataSource.getConnection(); // Get the connection in the try
    // block, directly from the WebLogic
    // datasource
    // do all the JDBC within this try block. You can pass the
    // connection to subordinate methods, but not to anywhere
    // that thinks it can use the connection later.
    rs.close(); // close any result set asap
    stmt.close(); // then close any statement asap
    // When you're done with JDBC
    con.close(); // close the connection asap
    con = null; // nullify it so the finally knows it's done
    catch (Exception e) {
    // do whatever catch stuff you want. You don't
    // need a catch block if you don't want one...
    finally {
    // It is important to close a JDBC connection ASAP when it's not needed.
    // without fail, and regardless of exit path. Do everything in your
    // finally block in it's own try-catch-ignore so everything is done.
    try { if (con != null) con.close();} catch (Exception ignore){}
    return ret;
    }

  • Connection Pooling doesn't work.

    Good day. all
    I've tested OracleConnectionPoolDataSource and OracleDataSource.
    And found that there is no performance difference. And connections are not pooled to my mind.
    My sample fill table with records, and than read and update concurrently it in two threads.
    Bellow is a code provided.
    <strong>
    A piece of logs</strong>: each time new connection is created.
    connection= oracle.jdbc.driver.OracleConnection@1198891
    0. updatedNumber= 1
    connection.close()= oracle.jdbc.driver.OracleConnection@1198891
    connection= oracle.jdbc.driver.OracleConnection@17725c4
    connection.close()= oracle.jdbc.driver.OracleConnection@17725c4
    list.size()= 10
    0, name_update0, name_desc0, name_status0, 2008-11-04, 2008-11-04.
    1, a1, c1, b1, 2008-11-04, 2008-11-04.
    viewing the logs I see that every time new connection is created in both cases whether I use OracleConnectionPoolDataSource or OracleDataSource.
    <strong>
    Question:</strong> Can anybody help me to understand how to use Connnection pooling? And how to see with my own eyes that it works?
    <strong>DDL</strong>:
    to run the program one should create table:
    {color:#000080}CREATE TABLE TEST_RECORD1 (
    ID NUMBER(10) NOT NULL PRIMARY KEY,
    NAME VARCHAR2(255 BYTE) ,
    STATUS VARCHAR2(255 BYTE) ,
    DESCRIPTION VARCHAR2(255 BYTE),
    START_DATE TIMESTAMP ,
    END_DATE TIMESTAMP
    );{color}
    <strong>
    Java Code</strong>:
    package test.jdbc;
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.ResultSetMetaData;
    import java.sql.SQLException;
    import java.sql.Statement;
    import java.util.ArrayList;
    import java.util.Date;
    import java.util.List;
    import javax.sql.ConnectionPoolDataSource;
    import javax.sql.DataSource;
    import oracle.jdbc.pool.OracleConnectionPoolDataSource;
    import oracle.jdbc.pool.OracleDataSource;
    public class TestConnectionPooling2 {
    static DataSource dataSource;
    /** number of iterations */
    static final long BASE_REPEAT_NUMBER = 5;
    static final long RECORDS_NUMBER = 10;
    public static void main(String[] args) throws Exception {
    //here you can change data source (pooled or no), but performance won''t change
    // setupDataSource( new OracleDataSource());
    setupDataSource(new OracleConnectionPoolDataSource());
    long startTime = System.currentTimeMillis();
    //clean table
    removeAllRecords("delete from test_record1");
    //insert records into table
    for (int i = 0; i &lt; RECORDS_NUMBER; i++) {
    insertRecord(i,
    "insert into TEST_RECORD1 (id,name,status, description, start_date, end_date) "
    + " values (?, ?, ?, ?, ?, ?)");
    //setup thread which queries data from table
    Thread th1 = new Thread("thread 1") {
    public void run() {
    for (int i = 0; i &lt; BASE_REPEAT_NUMBER; i++) {
    retrieveRecords("select * from test_record1 order by id asc");
    Thread.yield();
    //setup thread which updates data on table
    Thread th2 = new Thread("thread 2") {
    public void run() {
    for (int counter = 0; counter &lt; BASE_REPEAT_NUMBER; counter++) {
    for (int i = 0; i &lt; RECORDS_NUMBER; i++) {
    performSingleUpdate(counter, i,
    "update TEST_RECORD1 set name = ?, description=?, status=? where id=?");
    Thread.yield();
    th1.start();
    th2.start();
    //do not finish until threads work
    while (th1.isAlive() || th2.isAlive()) {
    Thread.yield();
    long endTime = System.currentTimeMillis();
    System.out.println("Execution time:" + (endTime - startTime) + " ms.");
    private static void performSingleUpdate(long counter, long i, String sql) {
    PreparedStatement stmt = null;
    Connection conn2 = getConnection();
    try {
    stmt = conn2.prepareStatement(sql);
    long temp = counter * 10 + i;
    stmt.setString(1, "name_update" + temp);
    stmt.setString(2, "name_desc" + temp);
    stmt.setString(3, "name_status" + temp);
    stmt.setLong(4, i);
    int updatedNumber = stmt.executeUpdate();
    System.out.println(counter + ". updatedNumber= " + updatedNumber);
    } catch (SQLException e) {
    e.printStackTrace();
    } finally {
    try {
    stmt.close();
    } catch (SQLException e) {
    e.printStackTrace();
    if (conn2 != null) {
    closeConnection(conn2);
    private static void removeAllRecords(String deleteAllSQL) {
    Statement stmt = null;
    Connection conn2 = getConnection();
    try {
    stmt = conn2.createStatement();
    int updatedNumber = stmt.executeUpdate(deleteAllSQL);
    System.out.println("Deleting all records. updatedNumber= " + updatedNumber);
    stmt.close();
    } catch (SQLException e) {
    e.printStackTrace();
    } finally {
    if (conn2 != null) {
    closeConnection(conn2);
    public static void retrieveRecords(String sql) {
    List list = new ArrayList();
    Statement stmt = null;
    ResultSet resultset = null;
    int recordsCounter = 0;
    Connection connection = getConnection();
    try {
    stmt = connection.createStatement();
    resultset = stmt.executeQuery(sql);
    while (resultset.next()) {
    Record newRecord = new Record();
    recordsCounter++;
    newRecord.setId(resultset.getLong("id"));
    newRecord.setName(resultset.getString("name"));
    newRecord.setDesc(resultset.getString("description"));
    newRecord.setStatus(resultset.getString("status"));
    newRecord.setStartDate(resultset.getDate("start_Date"));
    newRecord.setEndDate(resultset.getDate("end_Date"));
    list.add(newRecord);
    } catch (SQLException e) {
    e.printStackTrace();
    } finally {
    if (resultset != null)
    try {
    resultset.close();
    } catch (Exception e) {
    e.printStackTrace();
    if (stmt != null)
    try {
    stmt.close();
    } catch (Exception e) {
    e.printStackTrace();
    if (connection != null) {
    closeConnection(connection);
    StringBuilder sb2 = new StringBuilder("list.size()= " + list.size() + "\n");
    for (int i = 0; i &lt; list.size(); i++) {
    Record record = (Record)list.get(i);
    sb2.append(" " + record.toString() + "\n");
    System.out.println("" + sb2);
    public static void insertRecord(long counter, String sql) {
    PreparedStatement stmt = null;
    Connection conn2 = getConnection();
    try {
    stmt = conn2.prepareStatement(sql);
    stmt.setLong(1, counter);
    stmt.setString(2, "a" + counter);
    stmt.setString(3, "b" + counter);
    stmt.setString(4, "c" + counter);
    stmt.setTimestamp(5, new java.sql.Timestamp(System.currentTimeMillis()));
    stmt.setTimestamp(6, new java.sql.Timestamp(System.currentTimeMillis()));
    int updatedNumber = stmt.executeUpdate();
    System.out.println(counter + ".insertNumber= " + updatedNumber);
    } catch (SQLException e) {
    e.printStackTrace();
    } finally {
    try {
    stmt.close();
    } catch (SQLException e) {
    e.printStackTrace();
    if (conn2 != null) {
    closeConnection(conn2);
    // Initial methods
    private static void setupDataSource(OracleDataSource oracleDataSource) throws SQLException {
    OracleDataSource ds = oracleDataSource;
    ds.setUser("akhlystov");
    ds.setPassword("xallex");
    ds.setURL("jdbc:oracle:thin:@localhost:1521:abc");
    dataSource = ds;
    public static DataSource getDataSource() {
    return dataSource;
    private static void closeConnection(Connection connection) {
    if (conn != null) {
    return;
    System.out.println("connection.close()= " + connection + "\n");
    try {
    connection.close();
    } catch (SQLException e) {
    throw new RuntimeException(
    "application should not work when database can't close connection");
    static Connection conn;
    public static Connection getConnection() {
    * uncomment to test without any data source, single connection if ( conn ==
    * null){ try { conn = getDataSource().getConnection(); } catch
    * (SQLException e) { e.printStackTrace(); } } return conn;
    try {
    Connection connection =null;
    if ( getDataSource() instanceof ConnectionPoolDataSource){
    connection = ((ConnectionPoolDataSource)getDataSource()).getPooledConnection().getConnection();
    }else{
    connection = getDataSource().getConnection();
    System.out.println("connection= " + connection);
    return connection;
    } catch (SQLException e) {
    e.printStackTrace();
    throw new RuntimeException("application should not work when database is unavailable");
    // Record class
    static class Record {
    long id;
    String name;
    String desc;
    String status;
    Date startDate;
    Date endDate;
    public long getId() {
    return id;
    public void setId(long id) {
    this.id = id;
    public String getName() {
    return name;
    public void setName(String name) {
    this.name = name;
    public String getDesc() {
    return desc;
    public void setDesc(String desc) {
    this.desc = desc;
    public String getStatus() {
    return status;
    public void setStatus(String status) {
    this.status = status;
    public Date getStartDate() {
    return startDate;
    public void setStartDate(Date startDate) {
    this.startDate = startDate;
    public Date getEndDate() {
    return endDate;
    public void setEndDate(Date endDate) {
    this.endDate = endDate;
    public String toString() {
    return id + ", " + name + ", " + desc + ", " + status + ", " + startDate + ", " + endDate + ".";
    Edited by: Alexandr Khlystov on 04.11.2008 20:14

    The relevant documentation for the 9i JDBC drivers is here http://download.oracle.com/docs/cd/B10501_01/java.920/a96654/connpoca.htm#1056354.
    In the 9i JDBC driver world,there was a distinction between a connection pool (pooled connection) and a connection cache.
    A connection pool attempts to eliminate the overhead and resource consumption of connecting and disconnecting from the database. If the connection is going to be reused then no point in closing the connection just to open it up again.
    What performance gain were you looking for? You would only see a performance gain if your application was constantly opening and closing connections, requiring all the resources to setup and tear down database communications. Once a connection is established there is no difference in performance of the execution of SQL.
    You can see this with
    import java.sql.Connection;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import oracle.jdbc.pool.OracleConnectionPoolDataSource;
    import oracle.jdbc.pool.OracleDataSource;
    import oracle.jdbc.pool.OraclePooledConnection;
    public class TestConnectionCache {
      public static void exec(Connection conn) throws SQLException {
        ResultSet rs = conn.prepareStatement("select sys_context('USERENV','SESSIONID') from dual").executeQuery();
        rs.next();
        System.out.println("Session id: " + rs.getInt(1));
        conn.close();
      public static void main(String[] args) throws SQLException {
        OracleDataSource ods = new OracleConnectionPoolDataSource();
        ods.setUser("...");
        ods.setPassword("...");
        // Construct the jdbc url.
        String host     = "...";
        String port     = "...";
        String instance = "...";
        String url =
          "jdbc:oracle:thin:@//" + host + ":" + port + "/" + instance
        ods.setURL(url);
        // No connection re-use.
        exec(ods.getConnection());
        exec(ods.getConnection());
        // Connection re-use. (Connection pooling)
        OraclePooledConnection opc = (OraclePooledConnection)((OracleConnectionPoolDataSource)ods).getPooledConnection();
        exec(opc.getConnection());
        exec(opc.getConnection());
    }Produces output similar to:
    Session id: 4110149
    Session id: 4110150
    Session id: 4110151
    Session id: 4110151Note when connection pooliing is used, the database session id is the same. Calling close() did not close the physical connection.
    A connection cache is a layer on top of pooled connections that manages the creation and destruction of connections. It usually has limits as to how many connection it should open and the max number of connections to allow. Then when the cache is asked for a connection, it can return one that is not in use, or possibly create a new one.
    The later versions of the JDBC driver greatly simplify managing your connections and here is the note from the docs:
    Note:
    The previous cache architecture, based on OracleConnectionCache and OracleConnectionCacheImpl, is deprecated. Oracle recommends that you take advantage of the new architecture, which is more powerful and offers better performance.
    Any reason why your are not using a more recent JDBC driver?

  • WLS 10.0 JDBC connection pool shrink not working

    We seem to be having a problem with jdbc connection pools not shrinking. In the connection pool properties in the WLS console we have:
    Initial Capacity 4
    Maximum Capacity 15
    Shrink Frequency 900
    However when I look at the underlying xml config file (see below) the last two values above are not present in the config!
    Any ideas what is going on here?
    thankyou,
    Chris
    <?xml version='1.0' encoding='UTF-8'?>
    <jdbc-data-source xmlns="http://www.bea.com/ns/weblogic/90" xmlns:sec="http://www.bea.com/ns/weblogic/90/security" xmlns
    :xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wls="http://www.bea.com/ns/weblogic/90/security/wls" xsi:schemaLo
    cation="http://www.bea.com/ns/weblogic/920 http://www.bea.com/ns/weblogic/920.xsd">
    <name>mdmrDataSource</name>
    <jdbc-driver-params>
    <url>jdbc:oracle:thin:@(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = xxxrac01-vip.nzlxxx01.com) (PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP) (HOST = xxxrac02-vip.nzlxxx01.com) (PORT = 1521)) (LOAD_BALANCE = yes) (CONNECT_DATA =(SERVE
    R = DEDICATED) (SERVICE_NAME = xxxrac.nzlami01.com)))</url>
    <driver-name>oracle.jdbc.pool.OracleDataSource</driver-name>
    <properties>
    <property>
    <name>user</name>
    <value>xxx_comms</value>
    </property>
    <property>
    <name>fastConnectionFailoverEnabled</name>
    <value>true</value>
    </property>
    <property>
    <name>implicitCachingEnabled</name>
    <value>true</value>
    </property>
    <property>
    <name>connectionCachingEnabled</name>
    <value>true</value>
    </property>
    <property>
    <name>ONSConfiguration</name>
    <value>nodes=xxxrac1:6251,xxxrac2:6251</value>
    </property>
    </properties>
    <password-encrypted>xxx</password-encrypted>
    </jdbc-driver-params>
    <jdbc-connection-pool-params>
    <initial-capacity>4</initial-capacity>
    <test-connections-on-reserve>true</test-connections-on-reserve>
    <test-table-name>SQL SELECT 1 FROM DUAL</test-table-name>
    </jdbc-connection-pool-params>
    <jdbc-data-source-params>
    <jndi-name>jdbc/XXXX</jndi-name>
    <global-transactions-protocol>None</global-transactions-protocol>
    </jdbc-data-source-params>
    </jdbc-data-source>

    You are right that the XML seems to lask those other settings... Did you
    sae those settings from the console?
    This is what's in one of mine....
    <jdbc-connection-pool-params>
    <initial-capacity>0</initial-capacity>
    <max-capacity>300</max-capacity>
    <shrink-frequency-seconds>900</shrink-frequency-seconds>

  • ODBC Connection Pooling not working with 10g On Windows 2003

    I have a bog standard Windows 2003 machine and installed Oracle 10g on it. It seems that the ODBC Connection pooling is not working.
    I am using ASP and every time I try and render a simple page it is taking 4-5 seconds which is the time necessaru to create a database connection. ( Machine is 2.8 Ghz Xeon with 2 gigs of Ram)
    The following VB Code can be used to test that the pooling is not working. It creates 2 connections to the database. On oracle 10g on windows 2003, it takes 5 seconds to create the first connection, and another 5 seconds to create the second connection.
    When you run the same program on windows 2000 and oracle 9, the first connection take 3 seconds, and the second 0.05 seconds. ( The shorter time being due to the connection pooling)
    time1=timer()
    set conn=createobject("adodb.connection")
    Conn.Open "dsn=oracleDSN;uid=yourusername;pwd=yourpassword"
    time2=timer()
    msgbox time2-time1
    conn.close
    set conn=nothing
    time1=timer()
    set conn=createobject("adodb.connection")
    Conn.Open "dsn=oracleDSN;uid=yourusername;pwd=yourpassword"
    time2=timer()
    msgbox time2-time1
    conn.close

    ODBC Connection Pooling is controlled by the ODBC Driver Manager and defaults to off for every driver on every platform. Have you enabled connection pooling for your driver in the ODBC Data Source Administrator?
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

Maybe you are looking for

  • SUM function in a calculation

    Hi All, Hope all is well. I'm at an early beginner level with Discoverer/Oracle a) Have a calc to determine how many weeks it took from when the course ended that the instructor handed in the grade. Calc_DateDiff ROUND(( TRUNC(Final Grade Date)-TRUNC

  • TS2972 Using more than one Apple TV on same wireless network

    Sorry if this is answered elsewhere, but I have an Apple TV for the main home TV, and now want to add another Apple TV for elsewhere in my house. Can I have two or more Apple TVs using home sharing on the same home wireless network? I'm assuming that

  • Soap receiver adapter exception

    Hi, I am using SOAP receiver adapter to access a web service that is hosted on SAP Web AS (in this case it is the integration server Web AS). I use the web services navigator to test the web service and the web service works fine. The name of the web

  • Smartform in PDF - Font Issue

    Hi All, I created a smartform and got the PDF output of the same using the function module FOPC_REPORT_SHOW_PDF. I created a smartstyle using Arial Font (REgular, Size 12) and I have used this smartstyle in the smartform. When I displayed the smartfo

  • Error -1073807346 will get away when i run VI for second time

    This is the weird thing i open the vi for the first time and run it and it will put out the error : Error -1073807346 occurred at VISA Open in Prompt for com port.vi Possible reason(s): VISA:  (Hex 0xBFFF000E) The given session or object reference is