6 Replies Latest reply on Feb 17, 2003 6:18 PM by Koen Maes

    jboss-3.0.3_tomcat-4.1.12 MSSQL 2000 Connection problem, Ple

    David Newbie


      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 had the same problem with jboss-3.0.0+Tomcat-4.0.3 bundle. Jboss started up fine and other examples is working fine but I could never get it to talk to MSSQL 2000, I got Tomcat to talk to MSSQL 2000 fine using servlet.

      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 are my setup:

      1) My classpath is pointing to the three jar files:

      2) the three jar files are also in the /lib directory

      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

      <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


      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-->

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


      <config-property name="ConnectionURL" type="java.lang.String">jdbc:microsoft:sqlserver://hunter:1433;Selec
      <config-property name="DriverClass" type="java.lang.String">com.microsoft.jdbc.sqlserver.SQLServerDriver</
      <!--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 -->
      <depends optional-attribute-name="OldRarDeployment">jboss.jca:service=RARDeployment,name=JBoss LocalTransa
      ction JDBC Wrapper

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

      <!--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

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

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

      <!--make the rar deploy! hack till better deployment-->

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

      <datasource-mapping>MS SQLSERVER2000</datasource-mapping>

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

      Thank you.

        • 1. Re: jboss-3.0.3_tomcat-4.1.12 MSSQL 2000 Connection problem,
          Sebastien ASTIE Newbie


          I have a question:
          Did you put the 3 jar files under %JBOSS_HOME%/lib or %JBOSS_HOME%/server/default/lib (assuming you run the default configuration)? If you didn't put them in the default configuration li folder, you might want try it.

          I use SQL Server 2000 with the Microsoft JDBC driver, and it works for me...

          I Hope it will work for you.


          • 2. Re: jboss-3.0.3_tomcat-4.1.12 MSSQL 2000 Connection problem,
            David Newbie

            Thank you for the Reply, yes I have the three jar files in both of the directory you specified and it still does not work. I would be greatly appreciated if you can attached your setup files.

            I was away, therefore I couldn't reply to you sooner.

            Thanks again,


            • 3. Re: jboss-3.0.3_tomcat-4.1.12 MSSQL 2000 Connection problem,
              David Newbie

              Thanks again for the reply. Yes, I have the three jar files in both places.

              Following is part of my log:

              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:
              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

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

              public Enumeration ejbFindByName(String name)
              throws RemoteException, FinderException {
              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) {
              try {
              connection = DriverManager.getConnection(dbUrl, userName, password);
              catch (SQLException e) {
              return connection;

              • 4. Re: jboss-3.0.3_tomcat-4.1.12 MSSQL 2000 Connection problem,
                David Jencks Master

                You aren't using the connection pooling/jca framework at all. Please look at the quickstart guide or perhaps one ot the testsuite examples.

                • 5. Re: jboss-3.0.3_tomcat-4.1.12 MSSQL 2000 Connection problem,
                  David Newbie

                  Maybe my terminology are wrong, but the simple matter is that I am having the problem of keep getting "no suitable driver", I think I am using JCA framework but not sure about connection pooling.

                  I did look at the quickstart guide but cannot find any testsuite examples that connect to MSSQL 2000 via JDBC.

                  It would help if you can tell me what I did wrong instead, if I can figure out from the quickstart guide then I wouldn't be posting it on here.

                  Thanks for you reply anyway.

                  • 6. Re: jboss-3.0.3_tomcat-4.1.12 MSSQL 2000 Connection problem,
                    Koen Maes Newbie

                    IMO: this happens when there's a typo in the connection URL ...