Replace Quotes, Connection Pooling, and Sun Web Server with MySQL, Oracle

This is code I use to insert data into my MySQL and Oracle databases.
I takes care of quotes and shows use of context, i.e. when you use Sun Web Server's
ConnectionPooling. This code works. Feel free to reply if you have questions on how to set up connection pooling using Sun Web Server 6.1SP - it took quite a long time to learn and I couldn't find much information throughout the web, so I hope this helps...
This is not a question and I am not looking for an answer, but please post comments or suggestions.
dailysun
This is in one class where I have a hashtable containing the
column name / value pairs that I want to enter into my table.
This class simply creates the SQL string from the values in the
hashtable. It then passes that hashtable including the database
name to a class which executes that sql statement (second code
portion).
/* Insert data into sf_parts. Create the column strings from
         * the provided hash table. Be sure to parse out hash elements which
         * are used for the createTemplate process
        StringBuffer values = new StringBuffer();
        StringBuffer fields = new StringBuffer();
        Enumeration keys = fieldHash.keys();
        while(keys.hasMoreElements()){
            Object currentKey = keys.nextElement();
                String fieldValue = (String) fieldHash.get(currentKey);
                if(values.length() >0){
                    values.append(",");
                values.append("'"+fieldValue.replaceAll("'","''")+"'"); // Takes care of quotes and various other special characters!
                if(fields.length() >0){
                    fields.append(",");
                fields.append(currentKey);
        sql = "INSERT INTO myTable (" + fields.toString() + ") VALUES (" + values.toString() + ");";
        String insertResult = caq.getInsertDelete(sql,"myDatabaseName"); // your database name is defined in web.xml and sun-web.xml when you use Sun Web Server's Connection Pooling.
        returnValue += "<br><br><b>Rows inserted into table(myTable): </b>" + insertResult + "<br>\n";
        And, like I describe above, this method executes the sql statement.
     * Takes care of insert, update and delete requests.
     * Must have set both dbName as well as the sql String.
     * Will return number of rows affected as String.
     * @return String Number of rows affected
     * @exception SQLException
     * @exception Exception
    public String getInsertDelete() {
        checkData(); // this simply checks if the variables dbName and sql are not empty ;-)
        InitialContext initContext = null;
        int rv = 0;
        try{
            // Get connection from configured pool
            initContext = new InitialContext();
            source = (DataSource) initContext.lookup("java:comp/env/jdbc/" + dbName); // I have this set up in web.xml and sun-web.xml (I use Sun Web Server 6.1SP which does connection pooling for me)
            conn = source.getConnection();
            if(conn != null){
                stmt = conn.createStatement();
                rv = stmt.executeUpdate(sql);
        }catch (SQLException e){
            // do something
        }catch (Exception e){
            // do something
        }finally{
            try{
                stmt.close();
            }catch(Exception e){
                // do something
            try{
                conn.close();
            }catch(Exception e){
                // do something
            try{
                initContext.close();
            }catch(Exception e){
                // do something
        return rv+"";
    }  

This is code I use to insert data into my MySQL and
Oracle databases.
I takes care of quotes and shows use of context, i.e.
when you use Sun Web Server's
ConnectionPooling. This code works. Feel free to
reply if you have questions on how to set up
connection pooling using Sun Web Server 6.1SP - it
took quite a long time to learn and I couldn't find
much information throughout the web, so I hope this
helps...
This is not a question and I am not looking for an
answer, but please post comments or suggestions.Using prepared statements would mean that you wouldn't have to worry about quotes.
You should be closing the result set.
You are handling all fields as strings. That won't work with time fields and might not work for numeric fields.
Presumably most of your variables are member variables. They should be local variables because that is the scope of the usage.
You must do something with the exceptions.
Hashtables although convienent mean that problems with usage can only be resolved at run time rather than compile time.

Similar Messages

  • Help! JDBC connection pooling lookup in Web server

    Hi,
    I have a probelm looking up a JDBC Resource
    whenever I try to do that I got the message saying:
    "sourceWEB3885: Name jdbc is not bound in this Context "
    I have created a connection pool and JDBC Resource
    <JDBCCONNECTIONPOOL name="mypool" datasourceclassname="oracle.jdbc.pool.OracleDataSource" steadypoolsize="8" maxpoolsize="32" poolresizequantity="2" idletimeout="300" maxwaittime="60000" connectionvalidationrequired="on" connectionvalidationmethod="auto-commit" validationtablename="test_table" failallconnections="off" isolationlevelguaranteed="on" transactionisolationlevel="read-uncommitted">
    <PROPERTY name="user" value="user"/>
    <PROPERTY name="URL" value="jdbc:oracle:thin:@10.10.10.10:1521:mydb"/>
    <PROPERTY name="password" value="password"/>
    </JDBCCONNECTIONPOOL>
    <JDBCRESOURCE jndiname="jdbc/mypoolds" poolname="mypool" enabled="true"/>
    I tried to lookup the data Resources like this:
    ic.lookup("java:comp/env/jdbc/paspoolds");
    I also tried other varaitions like
    ic.lookup("paspoolds");
    but without any luck.
    I'm not sure if the JDBC Resource didn't created properly or I didn't do the lookup properly.
    please advice.
    thanks.
    Ahmed

    I'm also getting the:
    [11/Nov/2004:16:35:30] warning ( 9818): WEB7103: Exception while binding global resources: javax.naming.NameNotFoundException: WEB3885: Name java:comp is not bound in this Context at org.apache.naming.NamingContext.lookup(NamingContext.java:811)
    Running Sun Java System Web Server 6.1...
    In sun-web.xml (I put 2 entries - just in case):
    <resource-ref>
    <res-ref-name>epdmDS</res-ref-name>
    <jndi-name>java:comp/env/jdbc/epdmDS</jndi-name>
    </resource-ref>
    <resource-ref>
    <res-ref-name>jdbc/epdmDS</res-ref-name>
    <jndi-name>java:comp/env/jdbc/epdmDS</jndi-name>
    </resource-ref>
    Web.xml:
    <resource-ref>
    <description> JNDI DataSource </description>
    <res-ref-name>epdmDS</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    <!-- <res-sharing-scope>Sharable</res-sharing-scope> -->
    </resource-ref>
    Java code:
    import javax.sql.DataSource;
    import javax.naming.InitialContext;
    private final static String jdbcPath = "java:comp/env/jdbc/epdmDS";
    createDS: {
    InitialContext ctx;
    // Instantiate data source objects and store in app context
    try {
    ctx = new InitialContext();
    DataSource epdmDS = (DataSource)ctx.lookup( jdbcPath );
    sc.setAttribute( "epdmDS", epdmDS );
    } catch( Exception e ) {
    logErr("EPDMServlet: Cannot create data source for EPDM jdbc path: "+jdbcPath );
    break createDS;
    server.xml: (I put in 2 just in case...trying to get it to work...)
    <JDBCCONNECTIONPOOL name="epdmDS" datasourceclassname="oracle.jdbc.pool.OracleDataSource" steadypoolsize="8" maxpoolsize="32" poolresizequantity="2" idl
    etimeout="300" maxwaittime="60000" connectionvalidationrequired="on" connectionvalidationmethod="auto-commit" validationtablename="" failallconnections="off"
    transactionisolationlevel="read-uncommitted" isolationlevelguaranteed="off">
    <PROPERTY name="User" value="xxx"/>
    <PROPERTY name="URL" value="jdbc:oracle:thin:@xxxxx:1525:xxxxx"/>
    <PROPERTY name="Password" value="xxx"/>
    </JDBCCONNECTIONPOOL>
    <JDBCRESOURCE jndiname="jdbc/epdmDS" poolname="epdmDS" enabled="on"/>
    <JDBCCONNECTIONPOOL name="epdmDS" datasourceclassname="oracle.jdbc.pool.OracleDataSource" steadypoolsize="8" maxpoolsize="32" poolresizequantity="2" idl
    etimeout="300" maxwaittime="60000" connectionvalidationrequired="on" connectionvalidationmethod="auto-commit" validationtablename="" failallconnections="off"
    transactionisolationlevel="read-uncommitted" isolationlevelguaranteed="off">
    <PROPERTY name="User" value="xxx"/>
    <PROPERTY name="URL" value="jdbc:oracle:thin:@xxxxx:1525:xxxxx"/>
    <PROPERTY name="Password" value="xxx"/>
    </JDBCCONNECTIONPOOL>
    <JDBCRESOURCE jndiname="jdbc/epdmDS" poolname="epdmDS" enabled="on"/>
    <JDBCRESOURCE jndiname="epdmDS" poolname="epdmDS" enabled="on"/>

  • Setting up Connection Pool in sun app server 8.1 with SQL server 2000

    Hello,
    I am trying to set up a connection pool & data source for SQL server 2000 (MSDE 2000).
    Here is what I attempted to do:
    I have a pool data source in a jar file called poll.jar and I copied it to C:\sun\Appserver\lib (Install dir\lib)
    com.microsoft.mspool.PoolDataSource is the pool data source class.
    In the Admin console, JDBC>Connection pools. Selected NEW and made the following entries.
    GENERAL SETTINGS
    Name: MsPool
    Datasource class name : com.microsoft.mspool.PoolDataSource
    Resource type: javax.sql.DataSource
    POOL SETTINGS: default values
    CONNECTION VALIDATION: default values
    TRANSACTION ISOLATION: default values
    PROPERTIES:
    DataSourceName:PoolDataSource
    NetworkProtocol:tcp
    DatabaseName: myDB
    Password:User specific
    user:User specific
    server: localhost
    PortNumber:1433
    I get the following error when I ping:
    Operation 'pingConnectionPool' failed in 'resources' Config Mbean. Target exception message: Class name is wrong or classpath is not set for : com.microsoft.mspool.PoolDataSource.
    Can any one help me if have a solution?
    Thanks in advance.
    mag

    You need to copy your jar to ${AS_INSTALL}/domains/domain1/lib/ext (replace domain1 by your
    domain). Another option is to leave the jar in ${AS_INSTALL}/lib and add a entry in the classpath-suffix element of your domain.xml.
    thanks,
    :aditya

  • Creating connection pool on Sun Application Server 8.1

    Hi All,
    I am trying to create a connection pool for my MySql database on Sun Application Server(Version 8.1) using 'asadmin'. I am also able to create the connection pool successfully but when i am trying to ping the connection pool, it is giving me the java.net.UnknownHostException. The command I am using for creating the connection pool is as follows:
    create-jdbc-connection-pool user admin password adminadmin host localhost port 4849 datasourceclassname com.mysql.jdbc.jdbc2.optional.MySqlConnectionPoolDataSource restype javax.sql.XADatasource --property User=root:Password=admin:SelectMethod=Cursor:DatabaseName=testdb:serverName=\"localhost\":portNumber=3306 MyConnectionPool
    My database and the application server are running on the same machine.
    Has anyone come across such a problem? Any help would be highly appriciated.
    Thanks in Advance,
    Anurag.

    hi Anurag,
    Check the properties in the jdbc-connection-pool tag and make sure that the values are populated correctly. You can also try specifying the actual hostname or IP address of the machine instead of localhost and see if that works.
    Cheers,
    Vasanth

  • How to create a connection pooling in Netbeans 6.0 using the oracle driver

    hi all,
    I am using Netbeans 6.0. Apache Tomcat 6.0.14 server, oracle 9i.
    I tried to create a connection pooling using tomcat web server.
    I have included the following code in context.xml and web.xml.
    CONTEXT.XML:
    <?xml version="1.0" encoding="UTF-8"?>
    <Context path="/network1">
    <Resource name="jdbc/myoracle"
    auth="Container"
    type="javax.sql.DataSource"
    username="scott"
    password="tiger"
    factory="BasicDataSourceFactory"
    driverClassName="oracle.jdbc.OracleDriver"
    url="jdbc:odbc:thin:@127.0.0.1:1521:mydb"
    maxActive="20"
    maxIdle="10"
    maxwait="-1"/>
    </Context>
    WEB.XML:
    <?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">
    <session-config>
    <session-timeout>
    30
    </session-timeout>
    </session-config>
    <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
    <resource-ref>
    <description>Oracle Datasource example</description>
    <res-ref-name>jdbc/myoracle</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>
    </web-app>
    After that i have included the following JDBC driver's jar files in the $Catalina_Home/lib folder.
    classes 111.jar,
    classes 111_g.jar
    classes12.jar
    classes 12_g.jar
    classes12dms.jar
    classes12dms_g.jar
    nls_charset11.jar
    nls_charset12.jar
    ocrs12.jar
    ojdbc14.jar
    ojdbc14_g.jar
    Then i stop the tomcat web server and start it again.
    In jsp page i have included the following code:
    Context ctx=new InitialContext();
    Context envctx=(Context)ctx.lookup("java:comp:env");
    DataSource ds=(DataSource)envctx.lookup("jdbc/myoracle");
    Connection con=ds.getConnection(); ----->(In this line an error occured that Connection class cannot be found.)
    please help me how to create a connection pooling and rectify the error in conneciton.
    Thanks in advance

    Please refer
    http://www.netbeans.org/kb/60/web/customer-book.html

  • Best way to use Sun Web Server connection pooling with Web Application?

    I have a number of applications that run Oracle and MySQL queries via Sun Web Server 6.1. I use the Web Server's built-in connection pooling, which works fairly well.
    As an interface with the connections I receive from the Web Server, I use a class, which (1) accepts the SQL and database name from a tool, (2) Opens the connection, runs the SQL, closes the connection, (3) puts the content of the result set into a Vector of Hashtables, (4) returns that Vector to the tool.
    Why do I use this Vector? That way, in my applications, I don't have to deal with opening connections (or getting them from the pool) and I don't have to worry about closing connections, because that's done automatically by the interface class.
    Is this a dumb approach to use? I'm a bit paranoid about open DB connections, because we have had a number of problems where connections would not be closed, go stale in oracle, and clog up the database resources.
    Can you suggest a better way to (1) smartly control opening and closing connections, and (2) enabling fast database access?
    Sorry, but given this Java/Sun Web Server double topic, I'm going to post the same message on the Web Server board.
    Any tips?
    dailysun
    P.S. For instance, in my tool, I call the interface class in this manner:
    Vector results_v = Database.getSelect("SELECT * FROM TEST","database1");
    getSelect uses the first string as the SQL and the second string as the jndi name of the Web server's database resource. getSelect does all the context stuff to get a connection from the pool, runs the SQL, puts the resultset into a Vector of Hastables (where each row is one Hashtable), and returns the Vector.

    I have a number of applications that run Oracle and MySQL queries via Sun Web Server 6.1. I use the Web Server's built-in connection pooling, which works fairly well.
    As an interface with the connections I receive from the Web Server, I use a class, which (1) accepts the SQL and database name from a tool, (2) Opens the connection, runs the SQL, closes the connection, (3) puts the content of the result set into a Vector of Hashtables, (4) returns that Vector to the tool.
    Why do I use this Vector? That way, in my applications, I don't have to deal with opening connections (or getting them from the pool) and I don't have to worry about closing connections, because that's done automatically by the interface class.
    Is this a dumb approach to use? I'm a bit paranoid about open DB connections, because we have had a number of problems where connections would not be closed, go stale in oracle, and clog up the database resources.
    Can you suggest a better way to (1) smartly control opening and closing connections, and (2) enabling fast database access?
    Sorry, but given this Java/Sun Web Server double topic, I'm going to post the same message on the Web Server board.
    Any tips?
    dailysun
    P.S. For instance, in my tool, I call the interface class in this manner:
    Vector results_v = Database.getSelect("SELECT * FROM TEST","database1");
    getSelect uses the first string as the SQL and the second string as the jndi name of the Web server's database resource. getSelect does all the context stuff to get a connection from the pool, runs the SQL, puts the resultset into a Vector of Hastables (where each row is one Hashtable), and returns the Vector.

  • Difference between using app server connection pooling and using the driver

    Hi all,
    How to get connection pooling with out application server and tomcat also?
    What is the difference between using app server connection pooling and using the driver supported connection pooling?
    Regards,
    Murali

    maybe the performance of App server pool is better than the JDBC pool,
    for you don't know wether the implementation of the JDBC interface is good or bad.

  • Setting up SSO between Sun Web Server and MS6.0

    Hi,
    I want to set up a trusted SSO between Sun Web server 6.1 and the MS6.0.The document does not give enough information about this.Any one done this before?
    Thanks,
    Ramnath

    I'd recommend to cross-post your inquiry to the Security

  • Oracle Application server connection pool and database links

    I am using Oracle application server 10g with connection pools, the db used by the application connects to another oracle db using a database link. My question is when the application starts it creates 10 connections, does it also create x amount of database links as well?

    Hi,
    Is there any way to use the connection pool or Datasource while connecting to database?If I am using a stateless sesssion bean and using a Data Access layer which just creates a database session to write the persistence toplink objects how I can make use of application server connection pool?Hi Vinod,
    Yes, TopLink allows you to use the app server's connection pooling and transaction services. Chapter 2 of the Oracle9iAS TopLink Foundation Library Guide provides details as do the TopLink examples. The easiest way to set this up is by using the sessions.xml file. The sample XML below is from the file <toplink903>\examples\ias\examples\ejb\sessionbean\sessions.xml. Here we are adding the datasource defined in OC4J and specifying that we are using the OC4J transaction controller also.
    <login>
    <user-name>sa</user-name>
    <password></password>
    <datasource>java:comp/env/jdbc/ejbJTSDataSource</datasource>
    <uses-external-transaction-controller>true</uses-external-transaction-controller>
    <uses-external-connection-pool>true</uses-external-connection-pool>
    </login>
    <external-transaction-controller-class>oracle.toplink.jts.oracle9i.Oracle9iJTSExternalTransactionController</external-transaction-controller-class>
    When using this approach you need to change your TopLink code slightly in the EJB methods:
    a. Acquire the ACTIVE unit of work from the server
    session (again, see the EmployeeSessionEJB code
    example) with something like:
    UnitOfWork uow = clientSession.getActiveUnitOfWork();
    b. Calls to uow.commit() can be ommitted or commented out
    because the EJB will handle this. Note that of course
    the methods you create in the EJB that are using this
    approach must have TX Required (default).
    Hope this helps.
    Pete

  • Using Sun Web Server 6.1 from the IDE

    Using JSE 8 with Sun Web Server 6.1 set as the target container, I have a SUNWS61deployment.xml file created.
    That didn't exist in JSE 7. Is it WS 6.1 SP4 or SP5 -related ?
    I also have ws61-sun-web.xml with a simple <sun-web-app/> tag (empty deployment descriptor).
    What should this file contain? Is it a replacement for sun-web.xml?
    Do I still need sun-web.xml? Its DTD declaration sounds like Sun
    App Server 7 (http://www.sun.com/software/sunone/appserver/dtds/sun-web-app_2_3-1.dtd)
    So you have plans to make "Sun Resources" (pools, JNDI resources, ...) created in the IDE be registerable directly in the Web Server just like it's possible with the sun app server?
    How safe is it to use JSE 8 with an older Web Server Service Pack (say 6.1SP1)?

    SUNWS61deployment.xml is created bythe IDE to be used internally and not to be used by the developer. This file wouldn't be sent to webserver after deployment.
    The ws61-sun-web.xml is sun-web.xml only and yes it is same as it is in Appserver7 as the webcontainer for both Webserver6.1 and Appserver7 are same. After deployment to webserver, ws61-sun-web.xml is renamed to Webserver as sun-web.xml by the IDE. When opened the developer can edit in the XML editor.
    The reason for having it as ws61-sun-web.xml in IDE is to avoid the clash between sun-web.xml of Appserver8.1 which is J2EE1.4 based whereas Webserver6.1 Web container is J2EE1.3 based.
    It should be okay to use any service pack of Webserver6.1 with JSE8
    Hope this helps

  • 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

  • Annoucing a few complimentary copies of Sun Web Server: Essentials Guide

    Dear Sun Web Server user,
    As you may have heard, found it on amazon.com or stumbled on it in the local book store like Borders or Barnes & Noble, there is a new book on Sun Web Server technology. If you haven't, no worries. Please refer to [t-5406033] or visit the [Essential Guide's web site|http://www.sunwebserver.com/].
    We are now pleased to announce availability of a few complimentary copies of the Essential Guide. We'll be raffling away the copies in the next few months. If you are interested in a free copy of the book, please read further to enter the raffle.
    It's easy to enter the raffle and get started:
    Step 1: If you haven't already done so, download, install and register.
    Step 2: Write a review of Sun Web Server product on Web Server's official page [1], and
    Step 3: Send us an email webserver at sun dot com, confirming your Step 1 along with a link to your review (Step 2).
    What happens next?
    We'll raffle at least a copy once in a month and the winner(s) will be notified. With may share the raffle results on with a permission from the lucky winners. If you are interested, get started today!
    [1] [Sun Web Server's official page|http://www.sun.com/webserver/].
    Disclaimer: Please note that the raffle is organized by the author(s), and that Sun Microsystems or Pearson Media - the publishers of The Essential Guide - are not responsible for the raffle.

    Hi mv,
    I probably mis-spoke. It is not so much the features that are missing in Sun Web Server, as it is the availability of additional user plugins. However, that being said, I chose Sun Web Server over Apache because of security and performance. I realize additional plugins could adversely affect both of those. I have emailed Sun marketing about a specific feature for Web Dav I would like to see. This would make things much easier for people who would like to do mass hosting virtual hosting. Most of the real valuable features that gave Apache an edge, the web server team has added in version 7. I have pasted a portion of the letter I emailed to Sun marketing below about Web Dav, and my logic behind it. This as well as being able to hook the user system into standard open source databases makes for a broader solution appeal. I realize I only have one view of the market, and these are just my two cents. :-) Thanks!
    TonyZ
    **** Letter ******
    I was introduced to Sun Web Server several years ago when we began looking at moving servers away from Microsoft technology and also bringing them into our facility. As a network and sys admin, I evaluated using different web servers out there as we had a few years to work on this project to ensure uptime and reliability. Initially, I found Sun Web Server quite confusing and looked at Apache. However, after the web interface was retooled, I found Sun Web Server quite simple and refreshing to use. Since we have to be CISP compliant for the credit card industry, security was very important to us. Not only from a code standpoint, but also from an accidental misconfiguration standpoint. In my opinion, Sun Web Server out shines Apache and other alternatives by a long shot.
    As far as the WebDav feature, what I have been looking at is how to expand and offer hosting and web services. I currently work for a small company which retails products on the web, and I also contribute to a few open source projects. Currently, I am working with http://www.mynajs.org/. We have been discussing how we could offer hosting for people wanting to try out the project. Hosting companies using Linux typically have deep hooks into the Linux operating system for managing users. For hosting, you have a whole specialized Linux stack with specialized disk quotas, users, ftp server with users based on Linux users, and mail. From my standpoint, while this works, it can become a nightmare as far as updates, system administration, patching, etc. For a business ROI, and technology footprint, this doesn't make sense. There are control panels out there that take care of some of this, but now you have another whole layer of technology to troubleshoot. If I do not want to use the Linux/Apache stack, and if I am using Java, and do not want to add Tomcat as well, what do I use? With Sun Web Server, I get the best of both worlds, one install, one piece of software, operating system separation, blazingly fast speed, out of the box clustering, one interface for management, standard serving as well as Java, and WebDav so that now I can eliminate an ftp server and reduce my footprint for security and maintenance headaches. One neat package. However, now I still have to manage and restrict users. How to do this using Sun Web Server? Right now, I have to either run an ftp server with quotas built in, or go back to the Linux operating system and work with specialized scripts an maintenance. In theory, if Sun Web Server had quotas, I have my user system with the controls I need. At the very least, if there were hooks to the WebDav system to perform custom processing on certain events, it would leave the door open for greater control of the user and system. Now if we want to offer a hosting solution, whether it be online storage, web hosting, or Java hosting, or social site, all we need is one product, Sun Web Server! With all of its features for enhancing performance, security, and much more. I might also add, that for a small companies, Sun Web Server has been a pretty much set it and forget it solution. It has been my experience for our servers to run pretty much without intervention once they are setup. With the watch dog process, if there is a problem, it is rarely noticed except for the admin watching the logs. Technically, I am not sure why anyone would choose something different than Sun Web Server. Apache is the hosting standard, but it is really Apache plus Linux. With a few more user features, I think Sun Web Server could replace the whole Apache/Linux stack, the Apache/Linux/Tomcat stack, outshine those solutions on heavy loads and high end features, and offer better ROI.

  • Need help with URL Redirect in Sun Web Server 7 u5

    All I am trying to do is redirect to a static URL and for the life of me I can not get it to behave the way I would expect. I am new to Sun Web Server so I am just trying to use the Admin Console to set this up.
    Here is what I'm trying to do:
    Redirect from - http://www.oldsite.com/store/store.html?store_id=2154
    To - http://www.newsite.com/Stores/StoreFront.aspx?StoreId=2154
    Here's what I tried in the console.
    Added a new URL Redirect
    Set the Source to be Condition and set it to: '^/store_id=2154$' (quotes included)
    Then set the Target to: http://www.newsite.com/Stores/StoreFront.aspx?StoreId=2154
    Then for the URL Type I checked Fixed URL
    When I tested with: http://www.oldsite.com/store/store.html?store_id=2154 it did redirect as desired
    BUT
    When I tested with: "http://www.oldsite.com/store/store.html?store_id=5555" it too got redirected to the Target and I can't figure out how this second URL can satisfy the condition to get redirected.
    Any help is most appreciated.

    thanks for choosing sun web server 7
    it is simpler if you just edit the configuration files manually
    cd <ws7-install-root>/https-<hostname>/config/
    edit obj.conf or <hostname>-obj.conf (if there is one for you depending on your configuration so that it look something like)
    <Object name="default">
    AuthTrans..
    #add the folllowing line here
    <If defined $query>
    <If $urlhost =~ "/oldsite.com" and
    $uri =~ "/store/store.html" and
    $query =~ "store_id=2154" >
    NameTrans fn="redirect" from="/" http://www.newsite.com/Stores/StoreFront.aspx?StoreId=2154
    </If>
    </If>
    ..rest of the existing obj.conf. continues
    NameTrans...
    now, you can either do <ws7-install-root>/https-<hostname>/bin/reconfig -> to reload your configuration without any server downtime or <ws7-install-root>/https-<hostname>/bin/restart -> to restart the server
    if it did work out for your, you will need to run the following so that admin server is aware of what you just did
    <ws7-install-root>/bin/wadm pull-config user=admin config=<hostname> <hostname.domainname>
    hope this helps

  • Connection pooling and auditing on an oracle database

    Integration of a weblogic application with an oracle backend,
    Connection pooling, and auditing ,2 conflicting requirements ?
    Problem statement :
    We are in the process of maintaining a legacy client server application where
    the client is
    written in PowerBuilder and the backend is using an Oracle database.
    Almost all business logic is implemented in stored procedures on the database.
    When working in client/server mode ,1 PowerBuilder User has a one-to-one relation
    with
    a connection(session) on the oracle database.
    It is a requirement that the database administrator must see the real user connected
    to the database
    and NOT some kind of superuser, therefore in the PowerBuilder app each user connects
    to the database
    with his own username.(Each user is configured on the database via a seperate
    powerbuilder security app).
    For the PowerBuilder app all is fine and this app can maintain conversional state(setting
    and
    reading of global variables in oracle packages).
    The management is pushing for web-based application where we will be using bea
    weblogic appserver(J2EE based).
    We have build an business app which is web-based and accessing the same oracle
    backend app as
    the PowerBuilder app is doing.
    The first version of this web-based app is using a custom build connector(based
    on JCA standard and
    derived from a template provided by the weblogic integration installation).
    This custom build connector is essentially a combination of a custom realm in
    weblogic terms
    and a degraded connection pool , where each web session(browser) has a one-to-one
    relation
    with the back end database.
    The reason that this custom connector is combining the security functionality
    and the pooling
    functionality , is because each user must be authenticated against the oracle
    database(security requirement)
    and NOT against a LDAP server, and we are using a statefull backend(oracle packages)
    which would make it
    difficult to reuse connections.
    A problem that surfaced while doing heavy loadtesting with the custom connector,
    is that sometimes connections are closed and new ones made in the midst of a transaction.
    If you imagine a scenario where a session bean creates a business entity ,and
    the session bean
    calls 1 entity bean for the header and 1 entity bean for the detail, then the
    header and detail
    must be created in the same transaction AND with the same connection(there is
    a parent-child relationship
    between header and detail enforced on the back end database via Primary and Foreing
    Keys).
    We have not yet found why weblogic is closing the connection!
    A second problem that we are experincing with the custom connector, is the use
    of CMP(container managed persistence)
    within entity beans.
    The J2EE developers state that the use of CMP decreases the develoment time and
    thus also maintenance costs.
    We have not yet found a way to integrate a custom connector with the CMP persistence
    scheme !
    In order to solve our loadtesting and CMP persistence problems i was asked to
    come up with a solution
    which should not use a custom connector,but use standard connection pools from
    weblogic.
    To resolve the authentication problem on weblogic i could make a custom realm
    which connects to the
    backend database with the username and password, and if the connection is ok ,
    i could consider this
    user as authenticated in weblogic.
    That still leaves me with the problem of auditing and pooling.
    If i were to use a standard connection pool,then all transaction made in the oracle
    database
    would be done by a pool user or super user, a solution which will be rejected
    by our local security officer,
    because you can not see which real user made a transaction in the database.
    I could still use the connection pool and in the application , advise the application
    developers
    to set an oracle package variable with the real user, then on arrival of the request
    in the database,
    the logic could use this package variable to set the transaction user.
    There are still problems with this approach :
    - The administrator of the database can still not see who is connected , he will
    only see the superuser connection.
    - This scheme can not be used when you want to use CMP persistence , since it
    is weblogic who will generate the code
    to access the database.
    I thought i had a solution when oracle provided us with a connection pool known
    as OracleOCIConnectionPool
    where there is a connection made by a superuser, but where sessions are multiplexed
    over this physical pipe with the real user.
    I can not seem to properly integrate this OCI connectionpool into weblogic.
    When using this pool , and we are coming into a bean (session or entity bean)
    weblogic is wrapping
    this pool with it's own internal Datasource and giving me back a connection of
    the superuser, but not one for the real user,
    thus setting me with my back to the wall again.
    I would appreciate if anyone had experienced the same problem to share a possible
    solution with us
    in order to satisfy all requirements(security,auditing,CMP).
    Many Thanks
    Blyau Gino
    [email protected]

    Hi Blyau,
    As Joe has already provided some technical advice,
    I'll try to say something on engineering process level.
    While migrating an application from one technology to
    other, like client-server to n-tier in you case, customers and
    stakeholders want to push into the new system as many old
    requirements as possible. This approach is AKA "we must
    have ALL of the features of the old system". Mostly it happens
    because they don't know what they want. Ad little understanding
    of abilities of the new technology, and you will get a requirement
    like the one you have in you hands.
    I think "DBA must see real user" is one of those. For this
    type of requirements it can make sense to try to drop it,
    or to understand its nature and suggest alternatives. In this
    particular case it can be a system that logs user names,
    login and logout times.
    Blind copying of old features into an incompatible new architecture
    may endanger the whole project and can result in its failure.
    Hope this helps.
    Regards,
    Slava Imeshev
    "Blyau Gino" <[email protected]> wrote in message
    news:[email protected]...
    >
    Integration of a weblogic application with an oracle backend,
    Connection pooling, and auditing ,2 conflicting requirements ?
    Problem statement :
    We are in the process of maintaining a legacy client server applicationwhere
    the client is
    written in PowerBuilder and the backend is using an Oracle database.
    Almost all business logic is implemented in stored procedures on thedatabase.
    When working in client/server mode ,1 PowerBuilder User has a one-to-onerelation
    with
    a connection(session) on the oracle database.
    It is a requirement that the database administrator must see the real userconnected
    to the database
    and NOT some kind of superuser, therefore in the PowerBuilder app eachuser connects
    to the database
    with his own username.(Each user is configured on the database via aseperate
    powerbuilder security app).
    For the PowerBuilder app all is fine and this app can maintainconversional state(setting
    and
    reading of global variables in oracle packages).
    The management is pushing for web-based application where we will be usingbea
    weblogic appserver(J2EE based).
    We have build an business app which is web-based and accessing the sameoracle
    backend app as
    the PowerBuilder app is doing.
    The first version of this web-based app is using a custom buildconnector(based
    on JCA standard and
    derived from a template provided by the weblogic integrationinstallation).
    This custom build connector is essentially a combination of a custom realmin
    weblogic terms
    and a degraded connection pool , where each web session(browser) has aone-to-one
    relation
    with the back end database.
    The reason that this custom connector is combining the securityfunctionality
    and the pooling
    functionality , is because each user must be authenticated against theoracle
    database(security requirement)
    and NOT against a LDAP server, and we are using a statefull backend(oraclepackages)
    which would make it
    difficult to reuse connections.
    A problem that surfaced while doing heavy loadtesting with the customconnector,
    >
    is that sometimes connections are closed and new ones made in the midst ofa transaction.
    If you imagine a scenario where a session bean creates a business entity,and
    the session bean
    calls 1 entity bean for the header and 1 entity bean for the detail, thenthe
    header and detail
    must be created in the same transaction AND with the same connection(thereis
    a parent-child relationship
    between header and detail enforced on the back end database via Primaryand Foreing
    Keys).
    We have not yet found why weblogic is closing the connection!
    A second problem that we are experincing with the custom connector, is theuse
    of CMP(container managed persistence)
    within entity beans.
    The J2EE developers state that the use of CMP decreases the develomenttime and
    thus also maintenance costs.
    We have not yet found a way to integrate a custom connector with the CMPpersistence
    scheme !
    In order to solve our loadtesting and CMP persistence problems i was askedto
    come up with a solution
    which should not use a custom connector,but use standard connection poolsfrom
    weblogic.
    To resolve the authentication problem on weblogic i could make a customrealm
    which connects to the
    backend database with the username and password, and if the connection isok ,
    i could consider this
    user as authenticated in weblogic.
    That still leaves me with the problem of auditing and pooling.
    If i were to use a standard connection pool,then all transaction made inthe oracle
    database
    would be done by a pool user or super user, a solution which will berejected
    by our local security officer,
    because you can not see which real user made a transaction in thedatabase.
    I could still use the connection pool and in the application , advise theapplication
    developers
    to set an oracle package variable with the real user, then on arrival ofthe request
    in the database,
    the logic could use this package variable to set the transaction user.
    There are still problems with this approach :
    - The administrator of the database can still not see who is connected ,he will
    only see the superuser connection.
    - This scheme can not be used when you want to use CMP persistence , sinceit
    is weblogic who will generate the code
    to access the database.
    I thought i had a solution when oracle provided us with a connection poolknown
    as OracleOCIConnectionPool
    where there is a connection made by a superuser, but where sessions aremultiplexed
    over this physical pipe with the real user.
    I can not seem to properly integrate this OCI connectionpool intoweblogic.
    When using this pool , and we are coming into a bean (session or entitybean)
    weblogic is wrapping
    this pool with it's own internal Datasource and giving me back aconnection of
    the superuser, but not one for the real user,
    thus setting me with my back to the wall again.
    I would appreciate if anyone had experienced the same problem to share apossible
    solution with us
    in order to satisfy all requirements(security,auditing,CMP).
    Many Thanks
    Blyau Gino
    [email protected]

  • Listener EA2: database connection pool and connection revalidation

    Hi all,
    As one can expect from early adopter release there could be some bugs but I can't find any references in forum to my situation:
    * My 11g XE database and listener are starting as windows services when server boots operating system (Windows Server 2003 R2).
    * I configured my web server (unsupported Jetty 9.0.0.M1) to start as windows service when operating system starts.
    * Apex Listener 2.0.0.268.17.05 configured to connect with XE using JDBC thin driver with default settings (initial pool size 3, max statements 10, min connections 1, max connections 10, inactivity timeout 1800, abandoned connection timeout 900)
    * Because web server starts a bit faster than Oracle database when apex connects first time it gets "ORA-12528, TNS:listener: all appropriate instances are blocking new connections" (could be that database still starting but already registered service with listener)
    * From listener.log file I can see that all further connections made from Apex listener succeeds
    * When I try to open any apex page with browser I am getting 404 error and apex listener logs error (*time is 2 days after system startup*):
    2012-11-30 3:56:02 PM oracle.dbtools.common.config.db.DatabaseConfig badConfiguration
    SEVERE: The pool named: apex is not correctly configured, error: Listener refused the connection with the following error:
    ORA-12528, TNS:listener: all appropriate instances are blocking new connections
    ConnectionPoolException [error=BAD_CONFIGURATION]
         at oracle.dbtools.common.jdbc.ConnectionPoolException.badConfiguration(ConnectionPoolException.java:62)
         at oracle.dbtools.common.config.db.DatabaseConfig.badConfiguration(DatabaseConfig.java:146)
         at oracle.dbtools.common.config.db.DatabaseConfig.createPool(DatabaseConfig.java:168)
         at oracle.dbtools.common.config.db.DatabaseConfig.getConnection(DatabaseConfig.java:68)
         at oracle.dbtools.common.jdbc.ora.OraPrincipal.connection(OraPrincipal.java:25)
         at oracle.dbtools.apex.ModApexContext.getConnection(ModApexContext.java:320)
         at oracle.dbtools.apex.Procedure.getProcedure(Procedure.java:166)
         at oracle.dbtools.apex.OWA.validateProcedure(OWA.java:384)
         at oracle.dbtools.apex.security.Security.isValidRequest(Security.java:171)
         at oracle.dbtools.apex.ModApex.validateRequest(ModApex.java:233)
         at oracle.dbtools.apex.ModApex.doGet(ModApex.java:79)
         at oracle.dbtools.apex.ModApex.service(ModApex.java:263)
         at oracle.dbtools.rt.web.HttpEndpointBase.modApex(HttpEndpointBase.java:288)
         at oracle.dbtools.rt.web.HttpEndpointBase.service(HttpEndpointBase.java:127)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
         at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:665)
         <... Jetty web server stack ...>
         at java.lang.Thread.run(Unknown Source)
    2012-11-30 3:56:02 PM oracle.dbtools.rt.web.HttpEndpointBase modApex
    * Oracle listener log for same time (no errors here):
    30-NOV-2012 15:56:01 * (CONNECT_DATA=(CID=(PROGRAM=JDBC Thin Client)(HOST=__jdbc__)(USER=SYSTEM))(SERVICE_NAME=xe)(CID=(PROGRAM=JDBC Thin Client)(HOST=__jdbc__)(USER=SYSTEM))) * (ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1078)) * establish * xe * 0
    30-NOV-2012 15:56:01 * (CONNECT_DATA=(CID=(PROGRAM=JDBC Thin Client)(HOST=__jdbc__)(USER=SYSTEM))(SERVICE_NAME=xe)(CID=(PROGRAM=JDBC Thin Client)(HOST=__jdbc__)(USER=SYSTEM))) * (ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1079)) * establish * xe * 0
    30-NOV-2012 15:56:01 * (CONNECT_DATA=(CID=(PROGRAM=JDBC Thin Client)(HOST=__jdbc__)(USER=SYSTEM))(SERVICE_NAME=xe)(CID=(PROGRAM=JDBC Thin Client)(HOST=__jdbc__)(USER=SYSTEM))) * (ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1080)) * establish * xe * 0
    30-NOV-2012 15:56:01 * (CONNECT_DATA=(CID=(PROGRAM=JDBC Thin Client)(HOST=__jdbc__)(USER=SYSTEM))(SERVICE_NAME=xe)(CID=(PROGRAM=JDBC Thin Client)(HOST=__jdbc__)(USER=SYSTEM))) * (ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1081)) * establish * xe * 0
    * For some reason apex listener keeps first connection status and won't try to establish new connection if first attempt finished with ORA-12528
    * The same scenario is valid when at time of web server start oracle database/listener is not available - even if database and listener starts and apex successfully establishes further connections all apex pages gets 404 error
    * If I restart web server windows service (while oracle db and listener still running) browser opens apex pages without errors and apex listener does not log any errors
    * I know that I can avoid this error delaying start of web server windows service but it would be nice to have production release 2.x without such bugs

    Hi,
    Is there any way to use the connection pool or Datasource while connecting to database?If I am using a stateless sesssion bean and using a Data Access layer which just creates a database session to write the persistence toplink objects how I can make use of application server connection pool?Hi Vinod,
    Yes, TopLink allows you to use the app server's connection pooling and transaction services. Chapter 2 of the Oracle9iAS TopLink Foundation Library Guide provides details as do the TopLink examples. The easiest way to set this up is by using the sessions.xml file. The sample XML below is from the file <toplink903>\examples\ias\examples\ejb\sessionbean\sessions.xml. Here we are adding the datasource defined in OC4J and specifying that we are using the OC4J transaction controller also.
    <login>
    <user-name>sa</user-name>
    <password></password>
    <datasource>java:comp/env/jdbc/ejbJTSDataSource</datasource>
    <uses-external-transaction-controller>true</uses-external-transaction-controller>
    <uses-external-connection-pool>true</uses-external-connection-pool>
    </login>
    <external-transaction-controller-class>oracle.toplink.jts.oracle9i.Oracle9iJTSExternalTransactionController</external-transaction-controller-class>
    When using this approach you need to change your TopLink code slightly in the EJB methods:
    a. Acquire the ACTIVE unit of work from the server
    session (again, see the EmployeeSessionEJB code
    example) with something like:
    UnitOfWork uow = clientSession.getActiveUnitOfWork();
    b. Calls to uow.commit() can be ommitted or commented out
    because the EJB will handle this. Note that of course
    the methods you create in the EJB that are using this
    approach must have TX Required (default).
    Hope this helps.
    Pete

Maybe you are looking for