Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Oracle connection problem on SUN One

Oracle connection problem on SUN One

From: Knuutila Juha <jysky_at_cs.tut.fi.xx>
Date: 03 Feb 2005 12:20:03 +0200
Message-ID: <vp6y8e62be4.fsf@mustatilhi.cs.tut.fi>

We cannot establish oracle connection on applications running in SUN One application server.
Program fails to open connection at java.sql.SQLException: Closed Connection. Any suggestion how to configure application server?

Our environment:

        Oracle 9.2.0.3.0-32 
        Sun ONE Application Server 7.0.0_03c
        SunOS finsun1 5.9 Generic sun4u sparc SUNW,Ultra-4


The same test application can be run on command line with no problems.

java -classpath ".:/dba/u01/app/oracle/product/9.2.0.3.0-32/jdbc/lib/classes12.zip:/dba/u01/app/oracle/product/9.2.0.3.0-32/jdbc/lib/nls_charset12.zip" com.jk.TConnection

But fails when I deploy it on application server.

Application server log:
[03/Feb/2005:05:03:09] INFO (21523): CORE1116: Sun ONE Application Server 7.0.0_03c
[03/Feb/2005:05:03:13] INFO (21524): CORE5076: Using [Java HotSpot(TM) Server VM, Version 1.4.2_04] from [Sun Microsystems Inc.]
[03/Feb/2005:05:03:26] INFO (21524): JMS5023: JMS service successfully started. Instance Name = domain1_server1, Home = [/usr/bin].
[03/Feb/2005:05:03:34] INFO (21524): JTS5014: Recoverable JTS instance, serverId = [100]
[03/Feb/2005:05:03:35] INFO (21524): RAR5060: Install JDBC Datasources ...
[03/Feb/2005:05:03:35] INFO (21524): JMS5015: Install JMS resources ...
[03/Feb/2005:05:03:40] INFO (21524): WEB0100: Loading web module [mywar] in virtual server [server1] at [/mywar]
[03/Feb/2005:05:03:43] INFO (21524): HTTP3072: HTTP listener http-listener-1 [http://mysun1.kummeli.com:1024] ready to accept requests
[03/Feb/2005:05:03:43] INFO (21524): CORE3274: successful server startup
[03/Feb/2005:05:03:43] INFO (21524): CORE5053: Application onReady complete.
[03/Feb/2005:05:04:13] WARNING (21524): CORE3283: stderr: java.sql.SQLException: Closed Connection
[03/Feb/2005:05:04:13] WARNING (21524): CORE3283: stderr: at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
[03/Feb/2005:05:04:13] WARNING (21524): CORE3283: stderr: at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
[03/Feb/2005:05:04:13] WARNING (21524): CORE3283: stderr: at oracle.jdbc.oci8.OCIDBAccess.check_error(OCIDBAccess.java:2364)
[03/Feb/2005:05:04:13] WARNING (21524): CORE3283: stderr: at oracle.jdbc.oci8.OCIDBAccess.logon(OCIDBAccess.java:480)
[03/Feb/2005:05:04:13] WARNING (21524): CORE3283: stderr: at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:360)
[03/Feb/2005:05:04:13] WARNING (21524): CORE3283: stderr: at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:5
[03/Feb/2005:05:04:13] WARNING (21524): CORE3283: stderr: at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:325)
[03/Feb/2005:05:04:13] WARNING (21524): CORE3283: stderr: at java.sql.DriverManager.getConnection(DriverManager.java:512)
[03/Feb/2005:05:04:13] WARNING (21524): CORE3283: stderr: at java.sql.DriverManager.getConnection(DriverManager.java:171)
[03/Feb/2005:05:04:13] WARNING (21524): CORE3283: stderr: at com.jk.TConnection.connect(TConnection.java:53)
[03/Feb/2005:05:04:13] WARNING (21524): CORE3283: stderr: at _jasper._taulut2_jsp._jspService(_taulut2_jsp.java:69)
[03/Feb/2005:05:04:13] WARNING (21524): CORE3283: stderr: at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
[03/Feb/2005:05:04:13] WARNING (21524): CORE3283: stderr: at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
[03/Feb/2005:05:04:13] WARNING (21524): CORE3283: stderr: at com.iplanet.ias.web.jsp.JspServlet$JspServletWrapper.service(JspServlet.j
[03/Feb/2005:05:04:13] WARNING (21524): CORE3283: stderr: at com.iplanet.ias.web.jsp.JspServlet.serviceJspFile(JspServlet.java:368)
[03/Feb/2005:05:04:13] WARNING (21524): CORE3283: stderr: at com.iplanet.ias.web.jsp.JspServlet.service(JspServlet.java:287)
[03/Feb/2005:05:04:13] WARNING (21524): CORE3283: stderr: at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
[03/Feb/2005:05:04:13] WARNING (21524): CORE3283: stderr: at org.apache.catalina.core.StandardWrapperValve.invokeServletService(Standa20)
[03/Feb/2005:05:04:13] WARNING (21524): CORE3283: stderr: at org.apache.catalina.core.StandardWrapperValve.access$000(StandardWrapperV
[03/Feb/2005:05:04:13] WARNING (21524): CORE3283: stderr: at org.apache.catalina.core.StandardWrapperValve$1.run(StandardWrapperValve.
[03/Feb/2005:05:04:13] WARNING (21524): CORE3283: stderr: at java.security.AccessController.doPrivileged(Native Method)
[03/Feb/2005:05:04:13] WARNING (21524): CORE3283: stderr: at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve
[03/Feb/2005:05:04:13] WARNING (21524): CORE3283: stderr: at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:50
[03/Feb/2005:05:04:13] WARNING (21524): CORE3283: stderr: at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve
[03/Feb/2005:05:04:13] WARNING (21524): CORE3283: stderr: at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:50
[03/Feb/2005:05:04:13] WARNING (21524): CORE3283: stderr: at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:
[03/Feb/2005:05:04:13] WARNING (21524): CORE3283: stderr: at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:50
[03/Feb/2005:05:04:13] WARNING (21524): CORE3283: stderr: at com.iplanet.ias.web.connector.nsapi.NSAPIProcessor.process(NSAPIProcessor
[03/Feb/2005:05:04:13] WARNING (21524): CORE3283: stderr: at com.iplanet.ias.web.WebContainer.service(WebContainer.java:598)
[03/Feb/2005:05:04:13] SEVERE (21524): StandardWrapperValve[jsp]: Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException

        at com.jk.TConnection.listTables(TConnection.java:13)
        at _jasper._taulut2_jsp._jspService(_taulut2_jsp.java:78)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)



Test Class

package com.jk;

import java.sql.*;

public class TConnection
{
  private Connection connection_;   

  public String listTables()
  {
    // example code from java developer's almanac     

    StringBuffer sb = new StringBuffer();     

    try {

      // Gets the database metadata
      DatabaseMetaData dbmd = connection_.getMetaData();
      
      // Specify the type of object; in this case we want tables
      String[] types = {"TABLE"};
      ResultSet resultSet = dbmd.getTables(null, null, "%", types);
      

      // Get the table names
      while (resultSet.next()) {
        // Get the table name
        String tableName = resultSet.getString(3);
        
        // Get the table's catalog and schema names (if any)
        String tableCatalog = resultSet.getString(1);
        String tableSchema = resultSet.getString(2);

        sb.append("=> "+tableName+" - "+tableCatalog+ " - "+tableSchema);
      }
    } catch (SQLException e) {
      e.printStackTrace();

    }
    return sb.toString();
  }

  public void connect( String connection_string,

                       String username, String password)
  {
    try {
      String driverName = "oracle.jdbc.driver.OracleDriver";
      Class.forName(driverName);
      
      // Create a connection to the database
      connection_ = DriverManager.getConnection(connection_string, username, password);
      if( connection_ == null )
        System.out.println("NOT COnnected:"+connection_string + " - "+ username+"/"+password);

    } catch (ClassNotFoundException e) {
      e.printStackTrace();
    } catch (SQLException e) {
      e.printStackTrace();

    }
  }   

  public static void main(String []args)   {
    TConnection jcon = new TConnection();

    String uname = "USER";
    if( args != null && args.length > 0 )       uname = args[0];
    String passwd = "TTTT";
    if( passwd != null && args.length > 1 )       passwd = args[1];

    jcon.connect("jdbc:oracle:oci8:@MYDB", uname, passwd);     

    System.out.println(jcon.listTables());   }
} Received on Thu Feb 03 2005 - 04:20:03 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US