6 Replies Latest reply: Feb 23, 2010 12:41 PM by Joe Weinstein-Oracle RSS

    Weblogic Server 11g and JDBC connection

    User644496-Oracle
      Hi,
      I am not able to successfully create jdbc datasource for Oracle 10 g in the weblogic 11g server. I have tried Type 4 and Thin drivers but not able to connect to Oracle DB.
      Does anyone has exact steps to make succesful jdbc connection to Oracle 10g database.

      Error, if i use Data Direct Type 4 Driver:
      Connection test failed.
      Cannot load driver: com.ddtek.jdbc.oracle.OracleDriver


      Error, if I use Oracle Thin Driver:
      Connection test failed.
      The Network Adapter could not establish the connection
      oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
      oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:133)
      oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:199)
      oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:480)
      oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:413)
      oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:508)
      oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:203)
      oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:33)
      oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:510)
      com.bea.console.utils.jdbc.JDBCUtils.testConnection(JDBCUtils.java:505)
      com.bea.console.actions.jdbc.datasources.createjdbcdatasource.CreateJDBCDataSource.testConnectionConfiguration(CreateJDBCDataSource.java:450)
      sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      java.lang.reflect.Method.invoke(Method.java:597)
      org.apache.beehive.netui.pageflow.FlowController.invokeActionMethod(FlowController.java:870)
      org.apache.beehive.netui.pageflow.FlowController.getActionMethodForward(FlowController.java:809)
      org.apache.beehive.netui.pageflow.FlowController.internalExecute(FlowController.java:478)
      org.apache.beehive.netui.pageflow.PageFlowController.internalExecute(PageFlowController.java:306)
      org.apache.beehive.netui.pageflow.FlowController.execute(FlowController.java:336)
      ...


      Thanks,
      Ajay
        • 1. Re: Weblogic Server 11g and JDBC connection
          dvohra21
          Cannot load driver: com.ddtek.jdbc.oracle.OracleDriver
          The driver class is wrong. The driver class should be
          oracle.jdbc.OracleDriver
          Connection url should be
          jdbc:oracle:thin:@localhost:1521:orcl
          • 2. Re: Weblogic Server 11g and JDBC connection
            Joe Weinstein-Oracle
            Dvohra is wrong again. If you have the DD commercial drivers installed you can use them,
            and the driver class and URL are produced by the WebLogic console in all cases anyway.
            The most appropriate driver for you is the thin driver, as you have already tried. The problem
            is that the machine name on which the DBMS is running, and/or the SID of that DBMS is
            different than you gave the console, or the port number is wrong.
            Can you connect to your DBMS in any way at all? If you can connect via SQL-PLUS,
            show me the entry for this DBMS in your tnsnames.ora file, and I will show you the
            parameters you would give the console so WebLogic can connect too...
            Joe
            • 3. Re: Weblogic Server 11g and JDBC connection
              dvohra21
              I am not able to successfully create jdbc datasource for Oracle 10 g in the weblogic 11g server. I have tried Type 4 and Thin drivers but not able to connect to Oracle DB.

              Are the driver JAR files in the classpath? What is the error message.

              If Data Direct driver is in the classpath .
              Class.forName("com.ddtek.jdbc.oracle.OracleDriver");
              String url = "jdbc:bea:oracle://localhost:1521";
              Connection con = DriverManager.getConnection(url);

              The Network Adapter could not establish the connection is usually if connection url is wrong or the driver jar file is not in the classpath.

              Are the client and the server on the same host?
              Is a firewall installed between the client and the server?
              • 4. Re: Weblogic Server 11g and JDBC connection
                Joe Weinstein-Oracle
                DVohra is wrong again:

                If Data Direct driver is in the classpath .
                Class.forName("com.ddtek.jdbc.oracle.OracleDriver");

                String url = "jdbc:bea:oracle://localhost:1521";

                Wrong. The URL for the commercial DD drivers (com.ddtek)
                do not include "bea" in them.

                Connection con = DriverManager.getConnection(url);

                Wrong. Never use DriverManager calls in a middleware server
                or any high-performance multithreaded JDBC application. In
                the OP's case, he would be of course wanting to use WebLogic
                DataSources for getting connections.

                The Network Adapter could not establish the connection is usually if connection url is wrong or the driver jar file is not in the classpath.

                Wrong. That exception is directly from the driver. It could not
                happen if the driver jar wasn't in the classpath, which is a non-
                issue anyway because the dirver is shipped with WebLogic.
                • 5. Re: Weblogic Server 11g and JDBC connection
                  dvohra21
                  String url = "jdbc:bea:oracle://localhost:1521";

                  Wrong. The URL for the commercial DD drivers (com.ddtek)
                  do not include "bea" in them.

                  Seems like the documentation is wrong. The following connection url is taken from the following documentation.

                  String url = "jdbc:bea:oracle://myServer:1521";
                  http://download.oracle.com/docs/cd/E12840_01/wls/docs103/jdbc_drivers/oracle.html

                  The DataDirect documentation has the correct url.

                  jdbc:datadirect:oracle://server_name:1521
                  http://media.datadirect.com/download/docs/connectsqlxml/jdbcug/jquiksta.htm


                  Connection con = DriverManager.getConnection(url);
                  Wrong. Never use DriverManager calls in a middleware server
                  or any high-performance multithreaded JDBC application. In
                  the OP's case, he would be of course wanting to use WebLogic
                  DataSources for getting connections.

                  Thanks for the correction.
                  For Datasource
                  Context ctx = new InitialContext();
                  DataSource ds = (DataSource)ctx.lookup(“jdbc/EmployeeDB”);
                  Connection con = ds.getConnection(“OE”, “pw”);
                  The Network Adapter could not establish the connection is usually if connection url is wrong or the driver jar file is not in the classpath.

                  Wrong. That exception is directly from the driver. It could not
                  happen if the driver jar wasn't in the classpath, which is a non-
                  issue anyway because the dirver is shipped with WebLogic.
                  Thanks for the correction. The Network Adapter error could not be due to JAR file not being in the classpath.
                  The Network Adapter exception could be caused because:
                  1. The database host name, port number, or database instance name is wrong.
                  2. The database TNSListener has not been started. The TNSListener may be started with the lsnrctl utility.

                  C:\>lsnrctl start

                  Edited by: dvohra16 on Feb 23, 2010 10:17 AM

                  Edited by: dvohra16 on Feb 23, 2010 10:20 AM
                  • 6. Re: Weblogic Server 11g and JDBC connection
                    Joe Weinstein-Oracle
                    No, you do not understand the details of WebLogic+JDBC+drivers. WebLogic has a
                    relationship with DataDirect. We ship a rebranded 'weblogic' version of their drivers,
                    which the console offers as options for the pool's use, such as

                    weblogic.jdbc.sqlserver.SQLServerDriver
                    or
                    weblogic.jdbc.oracle.OracleDriver.

                    Those drivers take a URL (which is irrelvant anyway because the console will make the URL) like:
                    jdbc:weblogic:sqlserver:...
                    or
                    jdbc:weblogic:oracle:... etc.

                    In WLS 10.3.0 and before, these took a URL like jdbc:bea:..., but in current WeLogic versions
                    they need a URL as shown. If, on the other hand, a customer has already independently
                    purchased DataDirect's commercial dirvers, that have the com.ddtek class names, then they may
                    use them by putting them in WebLogic's classpath, and using the console to choose the relevant
                    com.ddtek class, and as usual, the console will create the correct URL for those drivers as
                    well.