Problem connect to SQL Server using JDBC

Discussions

EJB programming & troubleshooting: Problem connect to SQL Server using JDBC

  1. Problem connect to SQL Server using JDBC (2 messages)

    hi,allMy environment:
      WebLogic 5.1
      Jdk1.3
      SQL server 7.0
      Win NT
      JDBC for SQL Server7.0 is installed in c:\weblogic\mssqlserver4v70
    JDBC class is in c:\weblogic\mssqlserver4v70
    \classes\weblogic\jdbc\Driver.class
       What I config the pool in weblogic.properties is
    weblogic.jdbc.connectionPool.SQLPool=\
      url=jdbc:weblogic:mssqlserver4:ZhouDb@192.168.9.24:1433,\
      driver=weblogic.jdbc.mssqlserver4.Driver,\
      loginDelaySecs=1,\
      initialCapacity=3,\
      maxCapacity=3,\
      capacityIncrement=2,\
      allowShrinking=true,\
      shrinkPeriodMins=15,\
      refreshTestMinutes=10,\
      testTable=cabin,\
      props=user=zzz;password=0575817;server=192.168.9.24;\
    weblogic.jdbc.TXDataSource.weblogic.jdbc.jts.SQLPool=SQLPool
    weblogic.allow.reserve.weblogic.jdbc.connectionPool.SQLPool=everyone
    weblogic.allow.reset.weblogic.jdbc.connectionPool.SQLPool=everyone
    weblogic.allow.shrink.weblogic.jdbc.connectionPool.SQLPool=everyone

      using dbping is OK, that means, my JDBC for SQLServer7.0 is OK .
      But when program ,it give messages: Driver not found. Check Classpath:Java.lang.ClassNotFoundException:WebLogic.jdbc.mssqlserver4.Driver.

    Then I try a simple one,which is come with WebLogic 5.1,

    import java.sql.*;
    import java.applet.*;
    import java.awt.*;
    import java.io.*;
    import java.net.*;

     
    public class ConnectionApplet extends Applet
    {
      String url = "jdbc:weblogic:mssqlserver4:ZhouDb@ZJY:1433";
      String login = "zzz"; // Change to your database login
      String password = "0575817"; // Change to your password

      public void init()
      {
        try
          {

            Class.forName("weblogic.mssqlserver4v70.classes.weblogic.jdbc.mssqlserver4.Driver").newInstance();

          
            Connection connection = DriverManager.getConnection(url,login,password);

            message = "Connection was opened with " + url;

            connection.close();
          }

        catch(ClassNotFoundException ex)
          {
            message = "Exception: Driver wasn't found, check classpath: " + ex;
          }

        catch(Exception ex)
          {
            message = "Exception while opening the connection: " + ex;

            // Print the stack trace which shows where the problem is
            ex.printStackTrace(System.out);

          }

        catch(Error err)
          {
            message = "Error while opening the connection: " + err;

            // Print the stack trace which shows where the problem is
            err.printStackTrace(System.out);

          }

        System.out.println(message);

        repaint();

      }

      public void paint(Graphics graphics)
      {
        graphics.drawString(message,10,20);
      }

      String message = "";
    }

    When I run,it also give such message:
    Driver not found. Check Classpath:Java.lang.ClassNotFoundException:WebLogic.jdbc.mssqlserver4.Driver.

    How can I solve this problem?
    Hope to get your further help.Thanks.

    zhoujy


  2. Problem connect to SQL Server using JDBC[ Go to top ]

    hi
    i didn't go thru ur code fully but did u make additions to ur ejb-jar.xml and weblogic-jar.xml files regardding lookup for database

    somal
  3. The problem seems to be in the bad CLASSPATH variable.
    Is your driver name is "weblogic.mssqlserver4v70.classes.weblogic.jdbc.mssqlserver4.Driver" (as stated in init() method ) or it is "webLogic.jdbc.mssqlserver4.Driver" (as indicated in the exception)? Anyway, you should check if you path is correct.
    If your jdbc installation path is "c:\weblogic\mssqlserver4v70", and your driver class is webLogic.jdbc.mssqlserver4.Driver, you cannot access it as "weblogic.mssqlserver4v70.classes.weblogic.jdbc.mssqlserver4.Driver", put instead "c:\weblogic\mssqlserver4v70" into your CLASSPATH variable, and use "webLogic.jdbc.mssqlserver4.Driver" to load the driver.