11 Replies Latest reply on Feb 21, 2002 7:20 AM by Paul Schweinfurter

    Setup MSSQL JDBC driver from Microsoft

    chenchen hsiao Newbie

      Hi,

      I try to setup MS SQL JDBC driver and get the "java.lang.ClassCastException: com.microsoft.jdbc.sqlserver.SQLServerDriver". Please let me know how can I make it work. Thanks.


      In jboss.jcml,


      com.microsoft.jdbc.sqlserver.SQLServerDriver



      MSSQLServer
      com.microsoft.jdbc.sqlserver.SQLServerDriver
      jdbc:microsoft:sqlserver://chsiao:1433;user=xxx;password=xxx;server=chsiao
      database=mydb;port=1433;user=xxx;password=xxx;server=chsiao
      xxx
      xxx



      Error:

      [XADataSourceLoader] Starting
      [XADataSourceLoader] Stopped
      java.lang.ClassCastException: com.microsoft.jdbc.sqlserver.SQLServerDriver
      at org.jboss.jdbc.XADataSourceLoader.startService(XADataSourceLoader.java:345)
      at org.jboss.util.ServiceMBeanSupport.start(ServiceMBeanSupport.java:107)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
      at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
      at org.jboss.configuration.ConfigurationService$ServiceProxy.invoke(ConfigurationService.java:836)
      at $Proxy0.start(Unknown Source)
      at org.jboss.util.ServiceControl.start(ServiceControl.java:81)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
      at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
      at org.jboss.Main.(Main.java:210)
      at org.jboss.Main$1.run(Main.java:116)
      at java.security.AccessController.doPrivileged(Native Method)
      at org.jboss.Main.main(Main.java:112)
      [Configuration] java.lang.ClassCastException: com.microsoft.jdbc.sqlserver.SQLServerDriver
      [Configuration] at org.jboss.jdbc.XADataSourceLoader.startService(XADataSourceLoader.java:345)
      [Configuration] at org.jboss.util.ServiceMBeanSupport.start(ServiceMBeanSupport.java:107)
      [Configuration] at java.lang.reflect.Method.invoke(Native Method)
      [Configuration] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
      [Configuration] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
      [Configuration] at org.jboss.configuration.ConfigurationService$ServiceProxy.invoke(ConfigurationService.java:836)
      [Configuration] at $Proxy0.start(Unknown Source)
      [Configuration] at org.jboss.util.ServiceControl.start(ServiceControl.java:81)
      [Configuration] at java.lang.reflect.Method.invoke(Native Method)
      [Configuration] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
      [Configuration] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
      [Configuration] at org.jboss.Main.(Main.java:210)
      [Configuration] at org.jboss.Main$1.run(Main.java:116)
      [Configuration] at java.security.AccessController.doPrivileged(Native Method)
      [Configuration] at org.jboss.Main.main(Main.java:112)

        • 1. Re: Setup MSSQL JDBC driver from Microsoft
          Volker Krebs Newbie

          Hi,

          my MBean section looks like this and it works fine.
          I think its the DataSourceClass section which is wrong in your case.

          Volker


          jdbc/MSSQL/ProjectDB
          org.jboss.pool.jdbc.xa.wrapper.XADataSourceImpl

          jdbc:microsoft:sqlserver://grant:1433;DatabaseName=troja
          1200000
          sa
          0
          sa
          false
          false
          true
          false
          120000
          1800000
          true
          false
          1.0
          0

          • 2. Re: Setup MSSQL JDBC driver from Microsoft
            chenchen hsiao Newbie

            Thanks Volker, it works. I change the "DataSourceClass" and put the SQL server ip instead of server name.

            Thanks again.

            Chenchen

            • 3. Re: Setup MSSQL JDBC driver from Microsoft
              Paramjit S. Sarin Newbie

              Hi Volker,

              I have two instances of MSSQL Server on one box.
              Do you know what the URL setting is for this. Is there a parameter like ServerName alongwith the DatabaseName?
              For one instance of MSSQL it works fine.

              For two instances I get the error:

              jboss.jcml ---->


              SQLServerDBPool2
              org.jboss.pool.jdbc.xa.wrapper.XADataSourceImpl
              jdbc:microsoft:sqlserver://192.168.122.131:1433;DatabaseName=master;SelectMethod=cursor
              sa
              password

              ----------------------------------------------------

              ERROR .......>

              [SQLServerDBPool2] XA Connection pool SQLServerDBPool2 bound to java:/SQLServerD
              BPool2
              [XADataSourceLoader] Stopped
              java.lang.NullPointerException
              at org.jboss.pool.jdbc.xa.XAPoolDataSource.getConnection(XAPoolDataSourc
              e.java:178)
              at org.jboss.jdbc.XADataSourceLoader.startService(XADataSourceLoader.jav
              a:407)
              at org.jboss.util.ServiceMBeanSupport.start(ServiceMBeanSupport.java:107
              )
              at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
              sorImpl.java:28)
              at java.lang.reflect.Method.invoke(Method.java:313)
              at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:16
              28)
              at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:15
              23)
              at org.jboss.configuration.ConfigurationService$ServiceProxy.invoke(Conf
              igurationService.java:836)
              at $Proxy0.start(Unknown Source)
              at org.jboss.util.ServiceControl.start(ServiceControl.java:81)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
              java:42)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
              sorImpl.java:28)
              at java.lang.reflect.Method.invoke(Method.java:313)
              at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:16
              28)
              at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:15
              23)
              at org.jboss.Main.(Main.java:221)
              at org.jboss.Main$1.run(Main.java:127)
              at java.security.AccessController.doPrivileged(Native Method)
              at org.jboss.Main.main(Main.java:123)
              [Configuration] java.lang.NullPointerException

              • 4. Re: Setup MSSQL JDBC driver from Microsoft
                Volker Krebs Newbie

                Hello,

                > I have two instances of MSSQL Server on one box.
                > Do you know what the URL setting is for this. Is
                > there a parameter like ServerName alongwith the
                > DatabaseName?
                > For one instance of MSSQL it works fine.

                What do you mean with "two instances of MSSQL Server on one box" ?
                I actually don't know much about MSSQL Server, but
                if you are running two servers on your machine you have to use diffrent ports, I guess.

                Volker

                • 5. Re: Setup MSSQL JDBC driver from Microsoft
                  Paramjit S. Sarin Newbie

                  If I have only one instance of MSSQL on a box, and the name of the SQL Server instance is the same name of the box, then in the URL the instance (SQL Server) name defaults to the box name and it works.

                  But if there are two instances of SQL Server on a box, we have to give them different names, of the type
                  <box name>\<SQL instance name>. And I don't know how to specify this in the URL. Here's my entry in the jcml ....>
                  -------------------------------------------------------

                  SQLServerPool
                  org.jboss.pool.jdbc.xa.wrapper.XADataSourceImpl
                  jdbc:microsoft:sqlserver://192.168.116.192:1433;DatabaseName=Enterprise;SelectMethod=cursor
                  sa
                  potter

                  -------------------------------------------------------

                  Even if I have only one named entry (like <box\SQL server>) of MSSQL on a box, it doesn't work. Only if the box name and MSSQL server instance name are the same then it works with this URL. But then I can't create two instances of SQLserver.

                  thanks,
                  Param

                  • 6. Re: Setup MSSQL JDBC driver from Microsoft
                    Eddy Newbie

                    Hello Guys,
                    I just want to know how to set up the MSSQL JDBC Driver. I got the same error. Also, you mention the jboss.cmpl in the message, what is it?

                    Thanks


                    Eddy

                    • 7. Re: Setup MSSQL JDBC driver from Microsoft
                      Matt Hicks Newbie

                      I have been working a lot with the Microsoft JDBC Driver lately and figured that I would pass along a couple of things (that other people have helped me out with). First, on your connection URL, append ';SelectMethod=cursor'. This is covered in the Microsoft documentation, and you may have trouble getting your connection pools to work without it.

                      Second is that this driver cannot handle BIGINT types. So if you use 'Long' values in your java code, you will need to change your Java Mapping or remove the Long to get CMP to work right.

                      Hope this helps you out.

                      • 8. Re: Setup MSSQL JDBC driver from Microsoft
                        Prashanth K. Salur Newbie

                        Hi,

                        Did anyone get this exception when using Microsoft SQL Server driver.

                        I am using JBoss 2.2.2 Server and my bean uses BMP with CMT.


                        java.sql.SQLException: [Microsoft][SQLServer JDBC Driver]Can't start a cloned connection while in manual transaction mode.

                        at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
                        at com.microsoft.jdbc.base.BaseConnection.getImplConnection(Unknown Source)
                        at com.microsoft.jdbc.base.BaseStatement.getImplConnection(Unknown Source)
                        at com.microsoft.jdbc.base.BaseStatement.getImplStatement(Unknown Source)
                        at com.microsoft.jdbc.base.BaseStatement.preProcessSQL(Unknown Source)
                        at com.microsoft.jdbc.base.BaseStatement.executeInternal(Unknown Source)
                        at com.microsoft.jdbc.base.BaseStatement.execute(Unknown Source)
                        at org.opentools.minerva.jdbc.StatementInPool.execute(StatementInPool.java:119)
                        at java.lang.reflect.Method.invoke(Native Method)
                        at org.jboss.ejb.plugins.BMPPersistenceManager.removeEntity(BMPPersistenceManager.java:393)
                        at org.jboss.ejb.EntityContainer.remove(EntityContainer.java:331)
                        at java.lang.reflect.Method.invoke(Native Method)
                        at org.jboss.ejb.EntityContainer$ContainerInterceptor.invoke(EntityContainer.java:692)
                        at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:208)
                        at org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:186)
                        at org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxInterceptorCMT.java:133)
                        at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:263)
                        at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:99)
                        at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:190)
                        at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:195)
                        at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:323)
                        at org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke(JRMPContainerInvoker.java:482)
                        at org.jboss.ejb.plugins.jrmp.interfaces.EntityProxy.invoke(EntityProxy.java:146)
                        at $Proxy15.remove(Unknown Source)
                        at java.lang.reflect.Method.invoke(Native Method)
                        at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:472)
                        at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:87)
                        at org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxInterceptorCMT.java:133)
                        at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:458)
                        at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:99)
                        at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:190)
                        at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:195)
                        at org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionContainer.java:271)
                        at org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke(JRMPContainerInvoker.java:392)
                        at java.lang.reflect.Method.invoke(Native Method)
                        at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
                        at sun.rmi.transport.Transport$1.run(Unknown Source)
                        at java.security.AccessController.doPrivileged(Native Method)
                        at sun.rmi.transport.Transport.serviceCall(Unknown Source)
                        at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
                        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
                        at java.lang.Thread.run(Unknown Source)


                        Thanks
                        Prashanth

                        • 9. Re: Setup MSSQL JDBC driver from Microsoft
                          Balamurugan Raman Newbie

                          Hi,
                          SQl server wont share the same port for the second instance (it is not like webserver config to share port 80 on HTTP1.1). you have to specify different port. eigher of your configuration ie. first or second instance you have to specify the port.
                          MDAC 2.6 and above can automatically detect port for odbc and oledb configuration with DBSERVERNAME\INSTANCENAME.
                          - Bala.

                          • 10. Re: Setup MSSQL JDBC driver from Microsoft
                            Paul Schweinfurter Newbie

                            I am changing from the weblogic driver for MS Sql server 7.0 to the Microsoft driver for MS Sql 2000. I have checked the usual cause of a "no suitable driver" exception, the class path, and verified that it is finding msbase.jar, mssqlserver.jar, and msutil.jar.

                            I have tried every thing posted so far, but I am still getting the following problem:

                            [INFO,MSSqlDS] Starting
                            [INFO,MSSqlDS] java.sql.SQLException: No suitable driver
                            [INFO,MSSqlDS] at java.sql.DriverManager.getConnection(Unknown Source)
                            [INFO,MSSqlDS] at java.sql.DriverManager.getConnection(Unknown Source)
                            [INFO,MSSqlDS] at org.jboss.pool.jdbc.xa.wrapper.XADataSourceImpl.getXAConnection(Unknown Sourc
                            e)
                            [INFO,MSSqlDS] at org.jboss.pool.jdbc.xa.wrapper.XADataSourceImpl.getXAConnection(Unknown Sourc
                            e)
                            [INFO,MSSqlDS] at org.jboss.pool.jdbc.xa.XAConnectionFactory.createObject(Unknown Source)
                            [INFO,MSSqlDS] at org.jboss.pool.ObjectPool.createNewObject(Unknown Source)
                            [INFO,MSSqlDS] at org.jboss.pool.ObjectPool.initialize(Unknown Source)
                            [INFO,MSSqlDS] at org.jboss.pool.jdbc.xa.XAPoolDataSource.initialize(Unknown Source)
                            [INFO,MSSqlDS] at org.jboss.jdbc.XADataSourceLoader.startService(XADataSourceLoader.java:403)
                            [INFO,MSSqlDS] at org.jboss.util.ServiceMBeanSupport.start(ServiceMBeanSupport.java:103)
                            [INFO,MSSqlDS] at java.lang.reflect.Method.invoke(Native Method)
                            [INFO,MSSqlDS] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
                            [INFO,MSSqlDS] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
                            [INFO,MSSqlDS] at org.jboss.configuration.ConfigurationService$ServiceProxy.invoke(Configuratio
                            nService.java:967)
                            [INFO,MSSqlDS] at $Proxy0.start(Unknown Source)
                            [INFO,MSSqlDS] at org.jboss.util.ServiceControl.start(ServiceControl.java:79)
                            [INFO,MSSqlDS] at java.lang.reflect.Method.invoke(Native Method)
                            [INFO,MSSqlDS] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
                            [INFO,MSSqlDS] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
                            [INFO,MSSqlDS] at org.jboss.Main.(Main.java:208)
                            [INFO,MSSqlDS] at org.jboss.Main$1.run(Main.java:110)
                            [INFO,MSSqlDS] at java.security.AccessController.doPrivileged(Native Method)
                            [INFO,MSSqlDS] at org.jboss.Main.main(Main.java:106)
                            [INFO,MSSqlDS] XA Connection pool MSSqlDS bound to java:/MSSqlDS
                            [INFO,MSSqlDS] java.sql.SQLException: No suitable driver
                            [INFO,MSSqlDS] at java.sql.DriverManager.getConnection(Unknown Source)
                            [INFO,MSSqlDS] at java.sql.DriverManager.getConnection(Unknown Source)
                            [INFO,MSSqlDS] at org.jboss.pool.jdbc.xa.wrapper.XADataSourceImpl.getXAConnection(Unknown Sourc
                            e)
                            [INFO,MSSqlDS] at org.jboss.pool.jdbc.xa.wrapper.XADataSourceImpl.getXAConnection(Unknown Sourc
                            e)
                            [INFO,MSSqlDS] at org.jboss.pool.jdbc.xa.XAConnectionFactory.createObject(Unknown Source)
                            [INFO,MSSqlDS] at org.jboss.pool.ObjectPool.createNewObject(Unknown Source)
                            [INFO,MSSqlDS] at org.jboss.pool.ObjectPool.getObject(Unknown Source)
                            [INFO,MSSqlDS] at org.jboss.pool.ObjectPool.getObject(Unknown Source)
                            [INFO,MSSqlDS] at org.jboss.pool.jdbc.xa.XAPoolDataSource.getConnection(Unknown Source)
                            [INFO,MSSqlDS] at org.jboss.jdbc.XADataSourceLoader.startService(XADataSourceLoader.java:412)
                            [INFO,MSSqlDS] at org.jboss.util.ServiceMBeanSupport.start(ServiceMBeanSupport.java:103)
                            [INFO,MSSqlDS] at java.lang.reflect.Method.invoke(Native Method)
                            [INFO,MSSqlDS] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
                            [INFO,MSSqlDS] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
                            [INFO,MSSqlDS] at org.jboss.configuration.ConfigurationService$ServiceProxy.invoke(Configuratio
                            nService.java:967)
                            [INFO,MSSqlDS] at $Proxy0.start(Unknown Source)
                            [INFO,MSSqlDS] at org.jboss.util.ServiceControl.start(ServiceControl.java:79)
                            [INFO,MSSqlDS] at java.lang.reflect.Method.invoke(Native Method)
                            [INFO,MSSqlDS] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
                            [INFO,MSSqlDS] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
                            [INFO,MSSqlDS] at org.jboss.Main.(Main.java:208)
                            [INFO,MSSqlDS] at org.jboss.Main$1.run(Main.java:110)
                            [INFO,MSSqlDS] at java.security.AccessController.doPrivileged(Native Method)
                            [INFO,MSSqlDS] at org.jboss.Main.main(Main.java:106)
                            [ERROR,MSSqlDS] Stopped
                            java.lang.NullPointerException
                            at org.jboss.pool.jdbc.xa.XAPoolDataSource.getConnection(Unknown Source)
                            at org.jboss.jdbc.XADataSourceLoader.startService(XADataSourceLoader.java:412)
                            at org.jboss.util.ServiceMBeanSupport.start(ServiceMBeanSupport.java:103)
                            at java.lang.reflect.Method.invoke(Native Method)
                            at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
                            at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
                            at org.jboss.configuration.ConfigurationService$ServiceProxy.invoke(ConfigurationService
                            .java:967)
                            at $Proxy0.start(Unknown Source)
                            at org.jboss.util.ServiceControl.start(ServiceControl.java:79)
                            at java.lang.reflect.Method.invoke(Native Method)
                            at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
                            at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
                            at org.jboss.Main.(Main.java:208)
                            at org.jboss.Main$1.run(Main.java:110)
                            at java.security.AccessController.doPrivileged(Native Method)
                            at org.jboss.Main.main(Main.java:106)
                            [ERROR,ConfigurationService] Unexpected error
                            java.lang.NullPointerException
                            at org.jboss.pool.jdbc.xa.XAPoolDataSource.getConnection(Unknown Source)
                            at org.jboss.jdbc.XADataSourceLoader.startService(XADataSourceLoader.java:412)
                            at org.jboss.util.ServiceMBeanSupport.start(ServiceMBeanSupport.java:103)
                            at java.lang.reflect.Method.invoke(Native Method)
                            at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
                            at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
                            at org.jboss.configuration.ConfigurationService$ServiceProxy.invoke(ConfigurationService
                            .java:967)
                            at $Proxy0.start(Unknown Source)
                            at org.jboss.util.ServiceControl.start(ServiceControl.java:79)
                            at java.lang.reflect.Method.invoke(Native Method)
                            at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
                            at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
                            at org.jboss.Main.(Main.java:208)
                            at org.jboss.Main$1.run(Main.java:110)
                            at java.security.AccessController.doPrivileged(Native Method)
                            at org.jboss.Main.main(Main.java:106)

                            Here is my config:


                            MSSqlDS
                            org.jboss.pool.jdbc.xa.wrapper.XADataSourceImpl
                            jdbc:microsoft:sqlserver//:192.168.0.2:1433;SelectMethod=cursor;DatabaseName=xxx
                            xx
                            xx
                            true
                            1
                            2

                            • 11. Re: Setup MSSQL JDBC driver from Microsoft
                              Paul Schweinfurter Newbie

                              It was a colon.
                              Never mind.