tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ryan Lissack <rliss...@buildonline.com>
Subject RE: Tomcat, Oracle and connection caching.
Date Fri, 06 Feb 2004 18:08:37 GMT
I have only used the oci driver under Oracle 9i. Our url looked something
like this though:

jdbc:oracle:oci:@TNS_ENTRY_NAME

where TNS_ENTRY_NAME is an entry in
[ORACLE_CLIENT_HOME]/network/ADMIN/tnsnames.ora

So for you, something like this ...

TNS_ENTRY_NAME =
(description=(address=(host=serverName)(protocol=tcp)(port=1521
))(connect_data=(sid=orcl))


-----Original Message-----
From: David Short [mailto:dshort@san.rr.com]
Sent: 06 February 2004 17:20
To: 'Tomcat Users List'
Subject: RE: Tomcat, Oracle and connection caching.


Still no luck.  Here's the output from the
System.getProperty("java.library.path"):

java.library.path=c:/orahome/bin;c:/orahome/jdbc/lib

Here's the code:

public class ResourceManagerListener implements ServletContextListener
  {
  private OracleConnectionCacheImpl ds = null;
  private Context ctx = null;

  public void contextInitialized(ServletContextEvent sce)
    {
    ServletContext application  = sce.getServletContext();

    /*
     * Get the JDBC URL, user, password and limit from the web.xml
     * context init parameters
     */
    String jdbcURL  = application.getInitParameter("jdbcURL");
    String user     = application.getInitParameter("user");
    String password = application.getInitParameter("password");
    String minLimit = application.getInitParameter("minLimit");
    String maxLimit = application.getInitParameter("maxLimit");
    try
      {
      ds = new OracleConnectionCacheImpl();
      ds.setURL(jdbcURL);
      ds.setUser(user);
      ds.setPassword(password);
      ds.setMinLimit(Integer.parseInt(minLimit));
      ds.setMaxLimit(Integer.parseInt(maxLimit));
      }
    catch (Exception e)
      {
>>>   application.log("Failed to create data source: " + e.getMessage());
<<< this is where it fails.
      }

    /*
      Initialize the database connection pool.
    */
    try
      {
      ctx = new InitialContext();
      ctx.lookup("java:comp/env/jdbc/altura");
      }
    catch (Exception e)
      {
      application.log("Failed to create database connection pool: " +
e.getMessage());
      }

    application.setAttribute("appDataSource", ds);
    }

  public void contextDestroyed(ServletContextEvent sce)
    {
    ServletContext application  = sce.getServletContext();
    application.removeAttribute("appDataSource");
    // Close the connections in the DataSource
    try
      {
      ds.close();
      }
    catch (java.sql.SQLException e)
      {}

    ds = null;
    }
  }

Here are the web.xml entries:

  <context-param>
    <param-name>jdbcURL</param-name>

<param-value>(description=(address=(host=serverName)(protocol=tcp)(port=1521
))(connect_data=(sid=orcl)))</param-value>
  </context-param>

  <context-param>
    <param-name>user</param-name>
    <param-value>userName</param-value>
  </context-param>

  <context-param>
    <param-name>password</param-name>
    <param-value>password</param-value>
  </context-param>

  <context-param>
    <param-name>maxLimit</param-name>
    <param-value>50</param-value>
  </context-param>

  <context-param>
    <param-name>minLimit</param-name>
    <param-value>5</param-value>
  </context-param>


and the Tomcat application error log message:

2004-02-06 08:57:05 Failed to create data source: No suitable driver


There is a strange twist.  If I use the oci8 driver, with the
ds.setMinLimit(Integer.parseInt(minLimit)); line above, this message appears
in the Tomcat application log.  If I comment out the line, no message
appears, but when I try to get a connection, I get the
java.sql.SQLException: No suitable driver message and the application fails.



-----Original Message-----
From: Ryan Lissack [mailto:rlissack@buildonline.com]
Sent: Friday, February 06, 2004 8:21 AM
To: 'Tomcat Users List'
Subject: RE: Tomcat, Oracle and connection caching.


Make sure that the directory containing the DLLs/SOs is in your java library
path.  You can check by printing System.getProperty("java.library.path"), if
it isn't there you can set it at vm startup (add
-Djava.library.path=/path/to/so)

-----Original Message-----
From: David Short [mailto:dshort@san.rr.com]
Sent: 06 February 2004 16:09
To: 'Tomcat Users List'
Subject: RE: Tomcat, Oracle and connection caching.


It requires the Oracle client DLLs (or .so files) to be installed in the
correct place and the path setup correctly.  I have tested my oci8
configuration with the JdbcCheck program supplied by Oracle and the oci8
driver works just fine without JNI.  For some reason, it's not working with
JNI.  I've been reading everything I can find on the subject and haven't
seen anything explicitly describing special configurations, outside of what
I've already tried, for JNI.  The documentation states to simply replace
thin with oci8 in the JDBCURL string.  Also, in researching this, I've found
that you need to replace the thin JDBCURL string as follows in the web.xml
file:

Thin driver:
<param-value>jdbc:oracle:thin:@serverName:1521:orcl</param-value>

oci8 driver:
<param-value>(description=(address=(host=serverName)(protocol=tcp)(port=1521
))(connect_data=(sid=orcl)))</param-value>

Not sure where to go from here.  Perhaps, if you had a few spare moments,
you could try the oci8 driver and see what you come up with?

Thanks

Dave
-----Original Message-----
From: Shapira, Yoav [mailto:Yoav.Shapira@mpi.com]
Sent: Friday, February 06, 2004 6:04 AM
To: Tomcat Users List
Subject: RE: Tomcat, Oracle and connection caching.



Howdy,
I have it running with the thin driver.  I haven't tried OCI.  Doesn't
the OCI driver require some system libraries that have to be declared in
the LD_LIBRARY_PATH or loaded via JNI?

Yoav Shapira
Millennium ChemInformatics


>-----Original Message-----
>From: David Short [mailto:dshort@san.rr.com]
>Sent: Friday, February 06, 2004 12:14 AM
>To: 'Tomcat Users List'
>Subject: Tomcat, Oracle and connection caching.
>
>Does anyone have Tomcat 4.1.x running with connection caching using the
>Oracle oci8 driver?  I can get it to work using the thin driver but it
>won't
>work with the oci8 driver.  The oci8 driver works just fine with the
test
>program provided by Oracle, so my configuration is right.  There's
>something
>about the OracleConnectionCacheImpl class that the oci8 driver doesn't
>like.
>
>Here's the error: java.sql.SQLException: No suitable driver
>
>Any help would be greatly appreciated.
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org




This e-mail, including any attachments, is a confidential business
communication, and may contain information that is confidential, proprietary
and/or privileged.  This e-mail is intended only for the individual(s) to
whom it is addressed, and may not be saved, copied, printed, disclosed or
used by anyone else.  If you are not the(an) intended recipient, please
immediately delete this e-mail from your computer system and notify the
sender.  Thank you.


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message