Easy JNDI + Connection Pool Question

This is an easy question:
Once I get the object represented by my connection pool from the
Weblogic JNDI tree, how do I get a connection from the returned object
of type weblogic.common.internal.ResourceAllocator?
I keep getting ClassCastExceptions. I have tried
ConnectionPoolDataSource, Connection, and DataSource.
String conPool = "weblogic.jdbc.connectionPool.demoPool";
try {
Object obj = ctx.lookup(conPool);
msg(DEBUG,"FROM LOOKUP" + obj.getClass().getName());
//DataSource ds = (DataSource)ctx.lookup(conPool);
//con = ds.getConnection();
} catch (NameNotFoundException e) {
// binding does not exist
msg(ERROR,"BINDING DOES NOT EXIST",e);
} catch (NamingException e) {
// a failure occurred
msg(ERROR,"NAMING FAILURE OCCURED",e);
} catch (Exception e) {
msg(ERROR,"SOME RANDOM ERROR",e);
Thanks,
-Jacob

"Jacob Meushaw" wrote in message
Once I get the object represented by my connection pool from the
Weblogic JNDI tree, how do I get a connection from the returned object
of type weblogic.common.internal.ResourceAllocator?
I keep getting ClassCastExceptions.
DataSource ds = (DataSource)ctx.lookup(conPool);I think, you must use narrow operation:
Object reference = ctx.lookup(conPool);
DataSource ds =
(DataSource) PortableRemoteObject.narrow (ds,DataSource.class);
I haven't got time to check it, but I hope that works.
Wojtek

Similar Messages

  • 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

  • Connection Pooling Questions

    Hi there,
    I was previously using the jferner/node-oracle module with the "generic-pool" (https://github.com/coopernurse/node-pool) module for connection pooling. 
    I'm trying out a setup with connection pooling with node-oracledb and have a few questions:
    * If an execute call fails with a connection i've retrieved from the pool, and I want to destroy that connection and remove it from the pool, how do I do that?  Is it done implicitly for me? 
    * Is there any way to validate a connection before it's used?  Or again, is this done implicitly?  Is there a way to toggle it on and off for perf tuning?
    * Is there any way to tune how frequently Oracle checks for idle connections?  (In generic-pool this was called reapIntervalMillis)
    * Is there any way to turn on any logging of how the connection pool behaves for development debugging?  I just want to make sure my setup is behaving as I think it should be.
    I'm making some good headway on getting the module working and it wasn't too difficult a conversion from node-oracle, either, that's good!
    -Matt

    You should release() bad connections to the pool so the pool can replace them.
    Validating connections is generally not worth it: between validation & use there could be a failure, so your executions need to handle errors anyway.  Why reduce scalability and performance by doing an extra "round trip" for validation? Also you can use FAN which can proactively clean up idle sessions in the session pool that are affected by the DB instance disappearing (due to network glitches etc).
    The client-side pool is handled by Oracle session pooling, so the algorithms are opaque.

  • Connection Pool Questions

    I have a JSP/Servlet application I am developing. I would like to create one OraclePooledConnection for the application. I then have a set of repository classes(CommonRepository, EmployeeRepository, etc) that access the database and create JavaBeans for the JSP's to use. I would like each of these repository classes to access the single OraclePooledConnection.
    Currently I have a DataSourceWrapper class that extends the OraclePooledConnection class. This DataSourceWrapper class is a singleton class, so I am assured of only one class and in the Init() function I call super(url, user, pwd). (Source is below.) It seems to work, but I am not positive in is creating a Connection Pool. How could I test this? If it is not how would I do this?
    TIA,
    Gerald
    public class DataSourceWrapper extends OraclePooledConnection
    * field containing the driver used to connect to the database
    private static String driver = null;
    * field containing the url address of the database
    private static String url = null;
    * field containing the user name used to connect to the database
    private static String user = null;
    * field containing the password used to connect to the database
    private static String pw = null;
    * handle to the current Repository instance
    private static DataSourceWrapper instance;
    * handle used to get a database connection
    private PooledConnection ds = null;
    * Private Class Constructor.
    * <P>
    * Only one instance of this class is ever wanted, which means this class is a
    * singleton class. To accomplish this, the Class Constructor scope is private
    * to this class only. A static function <code>getInstance()</code> is used to
    * create the initial instance of this class and passes the handle all other
    * classes that need to access it.
    public DataSourceWrapper() throws SQLException{
    //Initialize the DataSource
    super(url,user,pw);
    * Returns a handle to this singleton Repository object.
    * <P>
    * If first time the method has been called it creates a Repository object by
    * calling the Class Constructor. If this is not the first call to the method
    * it returns the stored reference to this object
    * @return static reference to this singleton Repository
    * @throws RepositoryException thrown if error occurs during initialization
    protected static DataSourceWrapper getInstance() throws SQLException {
    if (instance == null)
    instance = new DataSourceWrapper();
    return instance;
    public void finalize() {
    try {
    ds.close();
    } catch (Exception e) {} //Application is closing who cares
    * Sets the the database connection information
    * @param newDriver driver used to connect to database
    * @param newUrl url address used to connect to database
    * @param newUser user id used to connect to database
    * @param newPassword password used to connect to database
    public static void setConnectInfo(
    String newDriver,
    String newUrl,
    String newUser,
    String newPassword) {
    driver = newDriver;
    url = newUrl;
    user = newUser;
    pw = newPassword;
    }

    I have a JSP/Servlet application I am developing. I would like to create one OraclePooledConnection for the application. I then have a set of repository classes(CommonRepository, EmployeeRepository, etc) that access the database and create JavaBeans for the JSP's to use. I would like each of these repository classes to access the single OraclePooledConnection.
    Currently I have a DataSourceWrapper class that extends the OraclePooledConnection class. This DataSourceWrapper class is a singleton class, so I am assured of only one class and in the Init() function I call super(url, user, pwd). (Source is below.) It seems to work, but I am not positive in is creating a Connection Pool. How could I test this? If it is not how would I do this?
    TIA,
    Gerald
    public class DataSourceWrapper extends OraclePooledConnection
    * field containing the driver used to connect to the database
    private static String driver = null;
    * field containing the url address of the database
    private static String url = null;
    * field containing the user name used to connect to the database
    private static String user = null;
    * field containing the password used to connect to the database
    private static String pw = null;
    * handle to the current Repository instance
    private static DataSourceWrapper instance;
    * handle used to get a database connection
    private PooledConnection ds = null;
    * Private Class Constructor.
    * <P>
    * Only one instance of this class is ever wanted, which means this class is a
    * singleton class. To accomplish this, the Class Constructor scope is private
    * to this class only. A static function <code>getInstance()</code> is used to
    * create the initial instance of this class and passes the handle all other
    * classes that need to access it.
    public DataSourceWrapper() throws SQLException{
    //Initialize the DataSource
    super(url,user,pw);
    * Returns a handle to this singleton Repository object.
    * <P>
    * If first time the method has been called it creates a Repository object by
    * calling the Class Constructor. If this is not the first call to the method
    * it returns the stored reference to this object
    * @return static reference to this singleton Repository
    * @throws RepositoryException thrown if error occurs during initialization
    protected static DataSourceWrapper getInstance() throws SQLException {
    if (instance == null)
    instance = new DataSourceWrapper();
    return instance;
    public void finalize() {
    try {
    ds.close();
    } catch (Exception e) {} //Application is closing who cares
    * Sets the the database connection information
    * @param newDriver driver used to connect to database
    * @param newUrl url address used to connect to database
    * @param newUser user id used to connect to database
    * @param newPassword password used to connect to database
    public static void setConnectInfo(
    String newDriver,
    String newUrl,
    String newUser,
    String newPassword) {
    driver = newDriver;
    url = newUrl;
    user = newUser;
    pw = newPassword;
    }

  • Web service connection pooling question

    I have a web service running on a Win2003 machine. I am accessing it using a
    client implemented in an EJB. The server is running Weblogic 8.1 SP2. It
    works, but there are three things I would like to implement
    1) Connection timeouts. i.e. If the web service client attempts to connect
    and does not get any response back, such as when you try to access a machine
    at an address that does not exist. Note: I am already using
    setProperty("weblogic.webservice.rpc.timeoutsecs", "2") and
    bindingInfo.setTimeout(2) to set a read timeout (and this works).
    2) Connection pooling. The web service endpoint is reached using SSL, and
    establishing an SSL connection is expensive in terms of CPU and network
    latency. Can I pool a certain number of connections, and then use them when
    I access the web service? This would be faster than creating a new
    connection each time. Currently, I have one line of code that invokes the
    method on my web service and stores the result in an object. Any ideas?
    3) Connection limiting. I want to limit the maximum number of simultaneous
    invocations of my web service by this particular WebLogic instance. Does
    WebLogic allow me to do this?
    Thanks in advance.

    I have used connection pooling in tomcat using a servlets init method to set up the pool, but I am not sure how I could incorporate something similar with my web service. Maybe I'm just confused as to if a webservice is created when it connected to or does it live at the endpoint untill the container shuts down??!!

  • JBO Parameters + Connection Pooling Question

    I know that it is possible to pass in BC4J configuration parameters (such as jbo.dofailover) to the JVM via the -D parameter. It is unclear to me, though, how those parameters are actually used because I can also configure each application module in my app differently. If parameters are passed using the -D parameter, does that override any individual application module configuration settings at run-time?
    It looks like every application module instance, at runtime, creates a JDBC connection into the database. How can I put a cap on that or limit the entire application to X number of connections? Currently, I'm using a JDBC URL and I'm seeing the following behavior:
    * 10 users all using 12 application modules = 120 JDBC connections into Oracle. Ouch.
    If I were to switch over to a JDBC DataSource using the WebLogic JDBC Connection Pool driver, will this effectively take over JDBC connection pooling for my application? In other words, if I set that datasource to a maximum of 50 simultaneous connections, will this truly limit the app to 50 connections or will the maximum possible be 50 connections * 12 application modules = 600?!?
    Thanks!

    I know that it is possible to pass in BC4J configuration parameters (such as jbo.dofailover) to the JVM via the -D
    parameter. It is unclear to me, though, how those parameters are actually used because I can also configure each
    application module in my app differently. If parameters are passed using the -D parameter, does that override any
    individual application module configuration settings at run-time? .
    The configuration settings take precedence over VM parameters. Tthe following thread also
    contains some discussion regarding BC4J parameter precedence:
    Re: using OLB, PLL etc., on 10gAS on AIX and 10G AS on windows =>Very Urgen
    It looks like every application module instance, at runtime, creates a JDBC connection into the database. How can
    I put a cap on that or limit the entire application to X number of connections? Currently, I'm using a JDBC URL and
    I'm seeing the following behavior:.
    * 10 users all using 12 application modules = 120 JDBC connections into Oracle. Ouch..
    If connecting with a JDBC URL then BC4J's connection pool will be used to acquire application modules. The max size
    of a connection pool may be defined with the parameter jbo.maxpoolsize. However, if the application has been
    architected to simultaneously use 12 root application modules per application request/session then BC4J will require
    12 JDBC connections per user. Specifying a maximum pool size will simply cause the other users to wait for
    connections resulting in high latency and/or wait timeouts. So, you should probably plan on configuring the connection
    pool size to meet your average application demands or consider using fewer AMs.
    Please also note that the BC4J connection pool parameters apply to a single pool instance. So, if each application
    user is connecting as a different DB user then the jbo.maxpoolsize will apply to each DB user's connection pool only.
    If I were to switch over to a JDBC DataSource using the WebLogic JDBC Connection Pool driver, will this effectively
    take over JDBC connection pooling for my application?.
    Yes.
    In other words, if I set that datasource to a maximum of 50 simultaneous connections, will this truly limit the app to
    50 connections or will the maximum possible be 50 connections * 12 application modules = 600?!?.
    Depends upon WebLogic's implementation. However, if you have 50 simultaneous application requests and if each
    request requires 12 simultaneous ApplicationModule(s) then you will require 600 ApplicationModule(s) and these 600
    ApplicationModule(s) will require 600 JDBC connections.
    Hope this helps.
    JR

  • Problem with JNDI/LDAP AND connection pool

    I'm a newbie to Java but am attempting to write a servlet that retrieves info use to populate the contents of drop down menus. I'd like to only have to do this once. The servlet also retrieves other data (e.g. user profile info, etc ...). I'd like to be able to use the connection pool for all of these operations but I'm getting a compile error:
    public class WhitePages extends HttpServlet {
    ResourceBundle rb = ResourceBundle.getBundle("LocalStrings");
    public static String m_servletPath = null;
    public static String cattrs = null;
    public static String guidesearchlist[] = {};
    public static int isLocalAddr = 0;
    private int aeCtr;
    private String[] sgDNArray;
    private HashMap sgDN2DNLabel = new HashMap();
    private HashMap sgDN2SearchGuide = new HashMap();
    private String strport;
    private int ldapport;
    private String ldaphost;
    private String ldapbinddn;
    private String ldapbindpw;
    private String ldapbasedn;
    private int maxsearchcontainers;
    private int maxsearchkeys;
    private String guidesearchbases;
    private String guidecontainerclass;
    private String strlocaladdr;
    private String providerurl;
    // my init method establishes the connection
    // pool and then retrieve menu data
    public void init(ServletConfig config) throws ServletException {
    super.init(config);
    String strport = config.getInitParameter("ldapport");
    ldapport = Integer.parseInt(strport);
    String strconts = config.getInitParameter("maxsearchcontainers");
    maxsearchcontainers = Integer.parseInt(strconts);
    String strkeys = config.getInitParameter("maxsearchkeys");
    maxsearchkeys = Integer.parseInt(strkeys);
    ldaphost = config.getInitParameter("ldaphost");
    ldapbinddn = config.getInitParameter("ldapbinddn");
    ldapbindpw = config.getInitParameter("ldapbindpw");
    ldapbasedn = config.getInitParameter("ldapbasedn");
    guidesearchbases = config.getInitParameter("guidesearchbases");
    guidecontainerclass = config.getInitParameter("guidecontainerclass");
    strlocaladdr = config.getInitParameter("localaddrs");
    providerurl = "ldap://" + ldaphost + ":" + ldapport;
    /* Set up environment for creating initial context */
    Hashtable env = new Hashtable(11);
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.PROVIDER_URL, providerurl.toString());
    /* Enable connection pooling */
    env.put("com.sun.jndi.ldap.connect.pool", "true");
    StringTokenizer st = new StringTokenizer(guidesearchbases, ":" );
    String guidesearchlist[] = new String[st.countTokens()];
    for ( int i = 0; i < guidesearchlist.length; i++ ) {
    guidesearchlist[i] = st.nextToken();
    // Get a connection from the connection pool
    // and retrieve the searchguides
    StringBuffer asm = new StringBuffer(""); // This is the advanced search menu htmlobject buffer
    StringBuffer strtmpbuf = new StringBuffer(""); // This is the simple search menu htmlobject buffer
    try {
    StringBuffer filter = new StringBuffer("");
    filter.append("(objectclass=" + guidecontainerclass + ")");
    String[] attrList = {"dn","cn","searchguide"};
    SearchControls ctls = new SearchControls();
    ctls.setReturningAttributes(attrList);
    ctls.setSearchScope(SearchControls.SUBTREE_SCOPE);
    String attrlabelkey;
    sgDNArray = new String[guidesearchlist.length];
    for( int i = 0; i < guidesearchlist.length; i++ ) {
    // Search each of the namingspaces where
    // searchguides exist then build
    // the dynamic menus from the result
    DirContext ctx = new InitialDirContext(env);
    NamingEnumeration results = ctx.search(guidesearchlist, filter, ctls);
    I get a compile error:
    WhitePages.java:164: cannot resolve symbol
    symbol : method search (java.lang.String,java.lang.StringBuffer,javax.naming.directory.SearchControls)
    location: interface javax.naming.directory.DirContext
    NamingEnumeration results = ctx.search(guidesearchlist[i], filter, ctls);
    ^
    WhitePages.java:225: cannot resolve symbol
    symbol : variable ctx
    location: class OpenDirectory
    ctx.close();
    ^
    Can anyone help? If there is someone out there with JNDI connection pool experience I would appreciate your assistance!

    Manish
    The issue may not be related to the number of connections or the initial
    connections. Check your heap size (ms, mx). Turn on verbosegc. Your heap may
    not be big enough to accept the 25,000 rows.
    Bernie
    "Manish Kumar Singh" <[email protected]> wrote in message
    news:3e6c34ca$[email protected]..
    We are creating the result set with 25000 rows(each row has 56 columns) bygetting the connection using data source. With the initial capacity of the
    connection pool is 5 and the max capacity as 30 and grow connection as 1,
    the server gets out of memory exception, when we issue a new request, even
    after closing the previous connections.
    Now, if we change the initial capacity to 1 and rest all the things assame, the issue gets resolved and the server works fine.
    Could you please help me out in this regard????
    thanks in advance
    manish

  • Connection pools

    Hi,
    We are having around 25 tables from one data source. We have around 8 subject areas. My question is can we have as many connection pools as we can. I mean if I bring couple of subject areas in one connection pool and feel that if I bring in the third the physical layer joins would be confusing, can open another connection pool to bring in tabels for subject area 3,4 and continue. Do we have to have one connection pool for all subject area if they are coming from one source. Few tables are thier in almost all Subject areas. Is it advicable to use multiple connection pools from one source. Please advce.

    Thanks for your help Saichand. I was aware that we could do in BMM but physical I just came to know. Also I had to use one table for two diff subject areas. So i created an alias for of that table. I took this alias and created the physical joins, complex joins in BMM for a subjet area and it ran without errrors. When I went into presenation layer and tried to build a report it was erroring out saying table does not exist. It is looking for the alias table name and says no table found in DB. We cant keep the alias table also with the same name in Physical .. right? How do I resolve this alias table issue? this was the reason I asked about the connection pool question.

  • Tomcat 5.0.* global JNDI database connect pooling. complex config question

    Ok. I can't get global connection pooling to work in tomcat 5.0.24. (I am running windows xp pro)
    I am using MySQL (installed on the same machine) and I have succesfully worked through the tutorial titled "MySQL DBCP Example" found at http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html
    This example does not demonstrate global connection pooling, however. I want to share a single connection pool across all my web applications. I don't want a different connection pool for each webapp.
    So I define the connection pool JDBC resource in the conf/server.xml file under the <GlobalNamingResources> element.
    Here is the entire <GlobalNamingResources> element lifted from conf/server.xml:
    (Please overlook some of the formatting mistakes due to the <code> tag interpreting the xml as java.)
    <!-- Global JNDI resources -->
    <GlobalNamingResources>
        <Environment name="simpleValue" type="java.lang.Integer" value="30"/>
        <Resource name="UserDatabase"
                  auth="Container"
                  type="org.apache.catalina.UserDatabase"
                  description="User database that can be updated and saved">
        </Resource>
        <Resource name="jdbc/MySQL"
                  auth="Container"
                  type="javax.sql.DataSource"/>
        <ResourceParams name="UserDatabase">
            <parameter>
                <name>factory</name>
                <value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
            </parameter>
            <parameter>
                <name>pathname</name>
                <value>conf/tomcat-users.xml</value>
            </parameter>
        </ResourceParams>
        <ResourceParams name="jdbc/MySQL">
            <parameter>
                <name>factory</name>
                <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
            </parameter>
            <parameter>
                <name>maxActive</name>
                <value>100</value>
            </parameter>
            <parameter>
                <name>maxIdle</name>
                <value>30</value>
            </parameter>
            <parameter>
                <name>maxWait</name>
                <value>20000</value>
            </parameter>
            <parameter>
               <name>username</name>
               <value>webapp</value>
            </parameter>
            <parameter>
               <name>password</name>
               <value>******</value>
            </parameter>
            <parameter>
                <name>removeAbandoned</name>
                <value>true</value>
            </parameter>
            <parameter>
                <name>removeAbandonedTimeout</name>
                <value>3000</value>
            </parameter>
            <parameter>
                <name>logAbandoned</name>
                <value>true</value>
            </parameter>
            <parameter>
                <name>url</name>
                <value>jdbc:mysql://localhost:3306/javatest?autoReconnect=true</value>
            </parameter>
        </ResourceParams>
      </GlobalNamingResources>I am still trying to get the DBTest example (described in the link to the tomcat 5 docs above) to work, only now I want it to work using a global connection pool. So here is the contents of webapps/DBTest/WEB-INF/web.xml: (again, please overlook formatting difficulties :)
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
             http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
             version="2.4">
      <description>MySQL Test App</description>
      <resource-ref>
          <description>DB Connection</description>
          <res-ref-name>jdbc/MySQL</res-ref-name>
          <res-type>javax.sql.DataSource</res-type>
          <res-auth>Container</res-auth>
      </resource-ref>
    </web-app>The last thing I need to do, I think, is to include a <resourceLink> element in the context.xml file for this webapp. Now in tomcat 5.0.* it is not recommended that the <context> element appear in the conf/server.xml file. Instead, as I understand it, it should appear in either of the two following places (for a webapp called DBTest):
    $CATALINA_HOME/conf/[engine_name]/[host_name]/DBTest.xml
    $CATALINA_HOME/webapps/DBTest/META-INF/context.xmlSince I would eventually like to package each webapp in its own war file, I prefer the second option above. This will enable me to place the context.xml file within the .war file. Currently, however, I am not using .war files.
    For the DBTest webapp I have the following <context> element in webapps/DBTest/META-INF/context.xml:
    <context path="/DBTest" docBase="/DBTest" debug="1">
        <ResourceLink global="jdbc/MySQL" name="jdbc/MySQL" type="javax.sql.DataSource" />
    </context>Now, when I point my browser to http://localhost:8080/DBTest/test.jsp I get the following message:
    javax.servlet.ServletException: Unable to get connection, DataSource invalid: "org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null', cause: No suitable driver"
    For those who are interested, here is test.jsp:
    <%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <sql:query var="rs" dataSource="jdbc/MySQL">
    select id, foo, bar from javatest.testdata
    </sql:query>
    <html>
      <head>
        <title>DB Test</title>
      </head>
      <body>
      <h2>Results</h2>
    <c:forEach var="row" items="${rs.rows}">
        Foo ${row.foo}<br/>
        Bar ${row.bar}<br/>
    </c:forEach>
      </body>
    </html>Now I know that this is a very long and detailed question and that it is unlikely that anyone is even going to read down this far, let alone take the time to study all that XML, but if anyone is able to tell me why this setup does not allow global connection pooling, I will be pretty *@&$**% impressed. I only wish I had duke dollars to give.
    Jon

    Okay, I went back and double checked that I can get the DBTest example working. It is described here: http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html
    I was not able to get it working exactly according to the tutorial, though. I was required to put the <context> element not in the conf/server.xml but in conf/Catalina/localhost/DBTest.xml. Then, with the DBTest/WEB-INF/web.xml as above, I was able to get the DBTest example working. The output of test.jsp (described above also) is the following:
    Results
    Foo hello
    Bar 12345I would like to be able to put the <context> element in webapps/DBTest/META-INF/context.xml (as I think should be allowed) because then I would be able to include it in a war file that encompassed the entire web application. If I am forced to put the <context> element in a subdirectory of the conf directory, then I cannot include it in a war file and I will be unable to just drop my war files in the webapps directory and go. Instead I will have to drop my war files in the webapps directory, then go and fiddle around with the xml files in conf/Catalina/localhost/
    But if I move the <context> element into webapps/DBTest/META-INF/context.xml then the example stops working. When I put it back in conf/Catalina/localhost/DBTest.xml everything is fine again.
    Ok, no big deal. I guess my war file deployment will just have to be a little more complicated.
    But what if I want the resource to be global??? If I remove the <Resource> and <ResourceParams> elements from the webapp-specific <context> element and put them in the <GlobalNamingResource> element in the conf/server.xml file I should have a global resource, right? I did this, then added a resource link to the <context> element (see above), however, the example stops working. I have tried both with and without the <resource-ref> element in web.xml.
    Can some remarkably intelligent and knowledgeable person please explain to me how global resources work in tomcat 5.0, especially global JDBC connection pooling.
    Thanks,
    Jon

  • 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

  • Problem with creating Connection pool and JNDI, driver is not detected

    Hi,
    I have an issue with creating Connection Pool and JNDI.
    I'm using:
    - JDK 1.6
    - OS: Linux(ubuntu 8.10)
    - Netbeans IDE 6.5.1
    - Java EE 5.0
    - Apache Tomcat 6.0.18 Its lib directory contains all necessary jar files for Oracle database driver
    - Oracle 11g Enterprise
    My problem is that the Oracle database driver is not detected when I want to create a pool (it works pretty well and is detected without any problem when I create ordinary connection by DriverManager)
    Therefore after running:
    InitialContext ic = new InitialContext();
    Context context = (Context)ic.lookup("java:comp/env");
    DataSource dataSource = (DataSource)context.lookup("jdbc/oracle11g");
    Connection connection = dataSource.getConnection();and right after dataSource.getConnection() I have the following exception:
    org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'oracle.jdbc.OracleDriver'
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1136)
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
    at servlets.Servlet1.doPost(Servlet1.java:47)
    at servlets.Servlet1.doGet(Servlet1.java:29)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Thread.java:619)
    Caused by: java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:169)
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1130)
    ... 17 more
    My application context file (context.xml) is:
    <?xml version="1.0" encoding="UTF-8"?>
    <Context path="/WebApplication3">
      <Resource auth="Container"
                      driverClassName="oracle.jdbc.OracleDriver"
                      maxActive="8"
                      maxIdle="4"
                      name="jdbc/oracle11g"
                      username="scott"
                      password="tiger"
                      type="javax.sql.DataSource"
                      url="jdbc:oracle:thin:@localhost:1521:database01" />
    </Context>and my web.xml is:
        <resource-ref>
            <description>Oracle Datasource example</description>
            <res-ref-name>jdbc/oracle11g</res-ref-name>
            <res-type>javax.sql.DataSource</res-type>
            <res-auth>Container</res-auth>
        </resource-ref>
    ...I found similar threads in different forums including sun, such as
    http://forums.sun.com/thread.jspa?threadID=567630&start=0&tstart=0
    http://forums.sun.com/thread.jspa?threadID=639243&tstart=0
    http://forums.sun.com/thread.jspa?threadID=5312178&tstart=0
    , but no solution.
    As many suggest, I also tried to put context directly in the server.xml (instead of my application context) and referencing it by <ResourceLink /> inside my application context but it didn't work and instead it gave me the following message:
    org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '   ' for connect URL 'null'
    Has anyone succeeded in creating a connection pool with JNDI by using Tomcat 6 or higher ? If yes, could kindly explain about the applied method.
    Regards,

    Hello again,
    Finally I managed to run my application also with Tomcat 6.0.18. There was only two lines that had to be modified
    in the context.xml file (the context of my application project and not server's)
    Instead of writing
    <Context antiJARLocking="true" path="/WebApplication2">
        type="javax.sql.DataSource"
        factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
    </Context>we had to write:
    <Context antiJARLocking="true" path="/WebApplication2">
        type="oracle.jdbc.pool.OracleDataSource"
        factory="oracle.jdbc.pool.OracleDataSourceFactory"
    </Context>- No modification was needed to be done at server level (niether server.xml nor server context.xml)
    - I just added the ojdbc6.jar in $CATALINA_HOME/lib (I didn't even need to add it in WEB-INF/lib of my project)
    - The servlet used to do the test was the same that I presented in my precedent post.
    For those who have encountered my problem and are interested in the format of the web.xml and context.xml
    with Tomcat 6.0, you can find them below:
    Oracle server: Oracle 11g Enterprise
    Tomcat server version: 6.0.18
    Oracle driver: ojdbc.jar
    IDE: Netbeans 6.5.1
    The context.xml file of the web application
    <?xml version="1.0" encoding="UTF-8"?>
    <Context antiJARLocking="true" path="/WebApplication2">
        <Resource name="jdbc/oracle11g"
                  type="oracle.jdbc.pool.OracleDataSource"
                  factory="oracle.jdbc.pool.OracleDataSourceFactory"
                  url="jdbc:oracle:thin:@localhost:1521:database01"
                  driverClassName="oracle.jdbc.OracleDriver"
                  userName="scott"
                  password="tiger"
                  auth="Container"
                  maxActive="100"
                  maxIdle="30"
                  maxWait="10000"
                  logAbandoned="true"
                  removeAbandoned="true"
                  removeAbandonedTimeout="60" />
    </Context>The web.xml of my web application
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
        <resource-ref>
            <description>Oracle Database 11g DataSource</description>
            <res-type>oracle.jdbc.pool.OracleDataSource</res-type>
            <res-auth>Container</res-auth>
            <res-ref-name>jdbc/oracle11g</res-ref-name>
        </resource-ref>
        <servlet>
            <servlet-name>Servlet1</servlet-name>
            <servlet-class>servlets.Servlet1</servlet-class>
        </servlet>
        <servlet-mapping>
            <servlet-name>Servlet1</servlet-name>
            <url-pattern>/Servlet1</url-pattern>
        </servlet-mapping>
        <session-config>
            <session-timeout>
                30
            </session-timeout>
        </session-config>
        <welcome-file-list>
            <welcome-file>index.jsp</welcome-file>
        </welcome-file-list>
    </web-app>Ok, now I'm happy as the original problem is completely solved
    Regards

  • Connection pool utilization -  questions and problems.

    Hi,
    This is in context to JSP/Java/JPDK based web provider applcation. Appreciate it if anyone can add any input here -
    1)After adding dbPersonalization to my JSP portlets I noticed that the connections in my connection pool have maxed out. After the first few page renderings, it breaks. I am not sure if its an inherent problem in my design. But, I do know that it started happening soon after I add the dbPersonalization with all its required setups as specified. Could that be possible ? Besides the connectionmanager.xml file required by the dbPersonalization setup, I also have my own connection properties file where I specify the min and max connections in the pool for all my java classes/methods to make use of. Is there a chance that the connection pooling information from both the files are clashing each other ??
    2) On a related topic - I wanted to get some input on a design question. I have about 10 JSP Portlets on each of the four tabs of my Portal page, with each one instantiating one class (useBean) that contain methods to get data from the database. Now every single method of each of these classes, gets and puts a connection object from the pool.
    The question is if the frequency of getting a conn object in every method of every JSP portlet too expensive ? Would it be better to make use of one connection object common to all the methods in a class/JSP/portlet ?
    I had set the min to 6 and the max conns to 25 and it looks like very soon all 25 gets used, which wasnt happening before I added the dbPersonalization setup to my portlets. The dbPersonalizaiton is only for editDefaults though.
    regards
    -Ananth Makaram

    Ryan,
    as to your 7.2.1 problem: MANY people had that same issue and did revert to
    7.1.1 (I did the same after being unable to connect once I upgrade) So no
    worries - your AEBS is fine as it is working with 7.1.1
    For the second part, I am not a wifi guy, but check out the article on
    http://www.bbwexchange.com/pubs/2006/09/20/page1397-228167.asp
    maybe that will give you some idea about WiFi 2.0 and if you benefit from it!
    Joerg

  • Questions regarding Connection Pooling

    Hi
    i have some confusion regarding how connection pooling is implemented..i have been doing some digging in to this lately but the more i read the more confused i get. i have some doubts here, will any of the posters here kindly clear them
    a. Do i have to connect to my database via the DataSource method to take advantage of the connection pooling provided by my app server?..i have read conflicting information about this suggesting that Connection Pooling will not be provided to my app if i use DriverManager.getConnection()
    b. if i chose to use the DataSource method do i have to implement the ConnectionPoolDataSource interface to provide the connection pooling for my app?
    c. what is the best way to implement my own custom Connection pool?
    Thanx

    DriverManager.getConnection() literally creates, that is, builds a connection to the database using the values you previously supplied when you loaded the driver.
    A connection pool is an object that contains several already made connections to the database, and simply provides you with one of those existing connections. The confusion arises because a) the method name is frequently the same and b) the connection pool object calls the driver's getConnection() method to create several connections before lending any of them out.
    In other words:
    DriverManager.getConnection() builds a connection to the database.
    ConnectionPool.getConnection() fetches an existing connection.
    So, to answer your questions...
    A. This is correct. If you use DriverManager.getConnection(), you are indeed bypassing the Connection Pool entirely.
    B. I'm not familiar with DataSource specifically, but in general, a third party connection pool will either give you the interface (and you implement the details) or they will give you the class file containing the DataSource object. All you would have to do in the latter case is to import that file, then create a new instance of it using the new keyword ( DataSource foo = new DataSource(); ). I suspect DataSource is indeed the class file.
    C. Creating a connection pool is trivial and there are many examples of it - search on this forum or check out your favorite Java/JDBC programming book. Usually, the question "Should I use a connection pool and why?" is a more important question.

  • Questions on Connection Pooling

    I already read the documentations on data-sources.xml, but I still have questions. In the following data-sources.xml (for OC4J 9.0.3):
    <data-source
    class="com.evermind.sql.ConnectionDataSource"
    name="ccf"
    location="jdbc/ccf"
    xa-location="jdbc/xa/ccf"
    ejb-location="jdbc/ccfPool"
    url="jdbc:oracle:thin:@erb:1521:prod"
    connection-driver="oracle.jdbc.driver.OracleDriver"
    username="scott"
    password="tiger"
    max-connections="300"
    min-connections="5"
    max-connect-attempts="10"
    connection-retry-interval="1"
    inactivity-timeout="30"
    wait-timeout="30"
    />
    I know that if we want to use a connection pool, we should use "ejb-location" and it is the only one used for emulated data sources. I also know that both "location" and "xa-connection" are used for non-emulated data sources.
    Then my questions are:
    1) Does non-emulated data source mean that it can not used for connection pooling? In other words, both "location" and "xa-location" can not be used for connection pooling? The only one that can be used for connection pooling is "ejb-location"?
    2) How can I use a non-pooled connection? right now, I am using "location" for non-connnection pooling, is this the right way to do it? The documentation says that it will be deprecated in future release, then what should I use if I want a non-pooled connection? can I still use "ejb-location" by setting "min-connections" and "max-connections" to 1? This is assuming that we can NOT use "location" to get the data source.
    3) Putting the username and password in the data-sources.xml seems not be good from the security point of view. But, if I am using CMP, I must supply the username and password in the data-sources.xml. Is there another way around this?
    Thank you very much for the help in advance.
    Jingzhi

    Liu
    I may not answer all ur questions.But would like to share my experiences....
    3) U can set the username and password dynamically also...we use it in orion..so u should be able to use it in oc4j..as a matter of fact, we can set all the data-sources parameters dynamically(programmatically).
    1) I may not be correct 100 percent with this :but for pooling only ejb-location is used and for non pooling location is used.
    For non pooled connections also, use ejb-location and dont give any max and min connections..let it take the default values...
    I am not aware that Oracle is going to deprecate the location ..well it is good to hear this which will reduce some confusion..
    seems there is lot being raised on these topics..
    yugandhar

  • BPEL - Database Connection Pools, JNDI - How do you do it ?

    Scoured forum and BPEL developer and admin guides, and didn't find any good instructions on how to configure and use database pools for BPEL, except possibly this post nearly two years ago data-sources.xml and oc4j-ra.xml
    I suspect things may have changed some in two years ! Where can I find this info. Does anyone who has done it have step by step instructions ?

    You should have scoured better ;-)
    I had a problem that needed to be fixed with a connection pool. Check this post:
    Strange Toplink errors appearing
    It points to some documentation that will help you:
    http://download-uk.oracle.com/docs/cd/B31017_01/integrate.1013/b28994/adptr_db.htm#sthref528
    Basically you have to do the following:
    - look in the WSDL of your DB adapter. It will have a jca:address section. In this section you will see a jndi location, something like: eis/DB/<a_connection>. Make note of this location
    - on the server look for the file oc4j-ra.xml in <oracle_home>/j2ee/<oc4j_soa>/application-deployments/default/DbAdapter. Edit the file. In there are mappings that basically forward the object in location eis/DB/<a_connection> to jdbc/<connection>.
    E.g.:
    <connector-factory location="eis/DB/DBConnection1" connector-name="Database Adapter">
                    <config-property name="xADataSourceName" value="jdbc/DBConnection1DataSource"/>
                    <config-property name="dataSourceName" value="loc/DBConnection1DataSource"/>
                    <config-property name="platformClassName" value="oracle.toplink.platform.database.Oracle9Platform"/>
                    <config-property name="usesNativeSequencing" value="true"/>
                    <config-property name="sequencePreallocationSize" value="50"/>
                    <config-property name="defaultNChar" value="false"/>
                    <config-property name="usesBatchWriting" value="true"/>
                    <connection-pooling use="none">
                    </connection-pooling>
                    <security-config use="none">
                    </security-config>
            </connector-factory>Now copy one of these blocks and edit it so that the location matches your eis/DB/<a_connection> location. Map the dataSource and xaDataSource properties to jdbc/<connection> s (which you create in the next step)
    - go to the enterprise manager, click on the soa suite oc4j container, choose the 'administration' link. Click on the 'Go to task' icon for JDBC connections. Here you can create your connection pool, and db connection. Make sure the location of your JDBC connection matches what you have configured in the oc4j-ra.xml file.
    - restart your soasuite/bpel oc4j container
    - bob's your uncle ;-)
    HTH,
    Bas

Maybe you are looking for

  • HT4009 can i get my money back from an app

    The app was misleading . After I purchased it it did the same thing. Didn't work. May I please get my money back for it.

  • IOS 5 - Photo Frame

    Just wondering if anyone else is having the same issue... Since updating to iOS 5, I can no longer use the lock screen photo frame while streaming music/slideshow to the Apple TV2. Is it because I need to change a setting I'm unaware of?

  • Need F4 Help for custom container element based on partner type

    Hi Friends I am displaying customer details in custom container .In that custom container I have a field Partner number,Partner type etc etc.. I included F4 help for partner number field, In that I referenced the following field.Now its coming perfec

  • Clear mailbox expiration date

    Hello, With a Delphi application I can change the expiration dat of a GW-mailbox. But I can't figure out how to clear it. Who does ? Ralf Vellinga

  • Runtime Engine 6 and Windows XP

    Hi all, Ok, I created a vi in Labview 6.0i and compliled it. Installed Runtime Engine 6 on an XP machine where I want to run the VI. The problme I'm having is that the VI starts, but doesn;t seem to communicate with my instruments on the GPIB bus. Th