0 Replies Latest reply on Nov 26, 2002 5:27 PM by ngod

    jboss-3.0.3+Tomcat-4.1.12 bundle & MSSQL 2000 problem "no su

    ngod

      Hello,

      I keep getting "java.sql.SQLException: No suitable driver" when trying to connect to MSSQL 2000 using MS jdbc driver, I have jboss-3.0.3+Tomcat-4.1.12 bundle,
      I looked though all the postings and still could not figure out what I am missing, it seems like it could not find the jar files, but they're all there.

      Please help.

      Below is the Error message:
      **********************************************************

      1:31:41,821 INFO [STDOUT] setEntityContext
      01:31:41,937 INFO [STDOUT] ejbFindByName
      01:31:41,984 INFO [STDOUT] java.sql.SQLException: No suitable driver
      01:31:42,053 ERROR [LogInterceptor] EJBException, causedBy:
      java.lang.NullPointerException
      at com.brainysoftware.ejb.ProductBean.ejbFindByName(ProductBean.java:144)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.ejb.plugins.BMPPersistenceManager.callFinderMethod(BMPPersistenceManager.java:638)
      at org.jboss.ejb.plugins.BMPPersistenceManager.findEntities(BMPPersistenceManager.java:340)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.findEntities(CachedConnectionInter
      ceptor.java:323)
      ......................................

      Below is the piece of code that cause the problem, it's in the line "prepareStatement".
      **********************************************************


      public Enumeration ejbFindByName(String name)
      throws RemoteException, FinderException {
      System.out.println("ejbFindByName");
      Vector products = new Vector();
      Connection con = null;
      PreparedStatement ps = null;
      ResultSet rs = null;

      try {
      String sql = "SELECT ProductId " +
      " FROM ProductTest" +
      " WHERE ProductName=?";
      con = getConnection();
      ps = con.prepareStatement(sql);
      ps.setString(1, name);
      rs = ps.executeQuery();
      ............................
      .................................

      Below is the "getConnection" function:
      **********************************************************

      public Connection getConnection() {

      String dbUrl = null;
      String userName = null;
      String password = null;
      Context initialContext;
      Context environment;
      Connection connection = null;

      try {
      initialContext = new InitialContext();
      environment = (Context) initialContext.lookup("java:comp/env");
      dbUrl = (String) environment.lookup("dbUrl");
      userName = (String) environment.lookup("dbUserName");
      password = (String) environment.lookup("dbPassword");
      }
      catch (NamingException e) {
      System.out.println(e.toString());
      }
      try {
      connection = DriverManager.getConnection(dbUrl, userName, password);
      }
      catch (SQLException e) {
      System.out.println(e.toString());
      }
      return connection;
      }


      Below are my setup:
      **********************************************************

      1) My classpath is pointing to the three jar files:
      ------------------------------------------------------
      /usr/local/msSQLjdbc/lib/msbase.jar:/usr/local/msSQLjdbc/lib/mssqlserver.jar:/usr/local/msSQLjdbc/lib/msutil.ja

      2) the three jar files are also in the /lib directory
      ------------------------------------------------------
      lib/msbase.jar
      lib/mssqlserver.jar
      lib/msutil.jar

      3) my mssql-service.xml is as follow:
      ------------------------------------------------------
      <?xml version="1.0" encoding="UTF-8"?>

      <!-- ===================================================================== -->
      <!-- -->
      <!-- JBoss Server Configuration -->
      <!-- -->
      <!-- ===================================================================== -->



      <!-- ======================================================================-->
      <!-- New ConnectionManager setup for Microsoft SQL Server 2000 driver -->
      <!-- You may download the latest Microsoft JDBC driver from *Microsoft* -->
      <!-- http://msdn.microsoft.com/downloads/default.asp?url=/downloads/sample.asp?url=/MSDN-FILES/027/001/779
      /msdncompositedoc.xml&frame=true -->
      <!-- Build jmx-api (build/build.sh all) and view for config documentation -->
      <!-- ===================================================================== -->




      <!-- Include a login module configuration named MSSQLDbRealm.
      Update your login-conf.xml, here is an example for a
      ConfiguredIdentityLoginModule:

      <application-policy name = "MSSQLDbRealm">

      <login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule" flag = "required">
      <module-option name = "principal">yourprincipal</module-option>
      <module-option name = "userName">yourusername</module-option>
      <module-option name = "password">yourpassword</module-option>
      <module-option name = "managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=MSSQLDS</module-opti
      on>
      </login-module>

      </application-policy>

      NOTE: the application-policy name attribute must match SecurityDomainJndiName, and the
      module-option name = "managedConnectionFactoryName"
      must match the object name of the ConnectionManager you are configuring here.
      -->
      <!--comment out this line if you are using the MSSQLDbRealm above-->
      MSSQLDbRealm

      <depends optional-attribute-name="ManagedConnectionFactoryName">
      <!--embedded mbean-->


      MSSQLDS



      <config-property name="ConnectionURL" type="java.lang.String">jdbc:microsoft:sqlserver://hunter:1433;Selec
      tMethod=cursor;DatabaseName=extraitems</config-property>
      <config-property name="DriverClass" type="java.lang.String">com.microsoft.jdbc.sqlserver.SQLServerDriver</
      config-property>
      <!--set these only if you want only default logins, not through JAAS
      <config-property name="UserName" type="java.lang.String">sa</config-property>
      <config-property name="Password" type="java.lang.String"></config-property>-->



      <!--Below here are advanced properties -->
      <!--hack-->
      <depends optional-attribute-name="OldRarDeployment">jboss.jca:service=RARDeployment,name=JBoss LocalTransa
      ction JDBC Wrapper



      <depends optional-attribute-name="ManagedConnectionPool">
      <!--embedded mbean-->


      0
      50
      5000
      15
      <!--criteria indicates if Subject (from security domain) or app supplied
      parameters (such as from getConnection(user, pw)) are used to distinguish
      connections in the pool. Choices are
      ByContainerAndApplication (use both),
      ByContainer (use Subject),
      ByApplication (use app supplied params only),
      ByNothing (all connections are equivalent, usually if adapter supports
      reauthentication)-->
      ByContainer



      <depends optional-attribute-name="CachedConnectionManager">jboss.jca:service=CachedConnectionManager</depe
      nds>

      <depends optional-attribute-name="JaasSecurityManagerService">jboss.security:service=JaasSecurityManager</
      depends>

      java:/TransactionManager
      <!--make the rar deploy! hack till better deployment-->
      jboss.jca:service=RARDeployer





      4) Below are the changes I made in the standardjbosscmp-jdbc.xml
      ------------------------------------------------------

      java:/MSSQLDS
      <datasource-mapping>MS SQLSERVER2000</datasource-mapping>

      5) Below are the changes I made in the standardjaws.xml
      ------------------------------------------------------
      java:/MSSQLDS
      <type-mapping>MS SQLSERVER2000</type-mapping>
      false

      Thank you.