5 Replies Latest reply on Apr 30, 2003 2:24 AM by gerinjo

    jboss3.2, sql server 2000

    learner

      Hi All
      Is there any step-by-step resource available for sql server 2000 and Jboss 3.2 connectivity?
      If not, then how i can configure sql server 2000 with jboss 3.2.

        • 1. Re: jboss3.2, sql server 2000
          gerinjo

          Hi, I have the same problem. After copping the mssqlserver.jar file to jboss.home/server/default/lib I still get the ClassNotFoundException, when he try to load the driver!!!!!!

          Please Help!

          Thx Gerinjo

          • 2. Re: jboss3.2, sql server 2000
            gerinjo

            .... the stack trace......:


            throwable: (java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver); - nested throwable: (org.j
            boss.resource.JBossResourceException: Failed to register driver for: com.microsoft.jdbc.sqlserver.SQLServerDriver; - nes
            ted throwable: (java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver))
            at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:106)
            at com.sybit.witron.system.ejb.ServerServices.getConnection(ServerServices.java:206)
            at com.sybit.witron.system.ejb.workorder.WorkOrderBean.ejbCreate(WorkOrderBean.java:99)
            at java.lang.reflect.Method.invoke(Native Method)
            at org.jboss.ejb.plugins.BMPPersistenceManager.createEntity(BMPPersistenceManager.java:206)
            at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.createEntity(CachedConnectionInterceptor.jav
            a:270)
            at org.jboss.ejb.EntityContainer.createHome(EntityContainer.java:725)
            at java.lang.reflect.Method.invoke(Native Method)
            at org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityContainer.java:998)
            at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(EntitySynchronizationInterceptor.java:188)
            at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invokeHome(CachedConnectionInterceptor.java:
            215)
            at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:88)
            at org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java:91)
            at org.jboss.ejb.plugins.EntityLockInterceptor.invokeHome(EntityLockInterceptor.java:61)
            at org.jboss.ejb.plugins.EntityCreationInterceptor.invokeHome(EntityCreationInterceptor.java:28)
            at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:88)
            at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:243)
            at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:74)
            at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:92)

            • 3. Re: jboss3.2, sql server 2000
              jonlee

              Where did you put the msbase and msutil jars? Just a guess as I don't use SQLServer 2000 but they are required by the MS SQLServer driver according to the documentation.

              • 4. Re: jboss3.2, sql server 2000
                jvr

                OK, let me take a shot at answering this,

                Here's my setup

                Apache, JBOSS 3.2.0 bundled with Tomcat, SQLServer2000 on W2K Server.

                %JBOSS_DIST is the JBOSS install directory (in my case D:\jboss-3.2.0_tomcat-4.1.24\)

                The steps I followed were :

                1. Download and install the microsoft jdbc driver.

                2. Copy the msbase.jar, mssqlserver.jar and msutil.jar files from the C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib directory(or wherever you installed it) to the %JBOSS_DIST%\server\default\lib directory.

                3. Copy the mssql-ds.xml file from the %JBOSS_DIST%\docs\examples\jca directory into the %JBOSS_DIST%\server\default\deploy directory.

                4. Modify the mssql-ds.xml file with the appropriate values.
                Eg.
                here's what my mssql-ds.xml file looks like

                <local-tx-datasource>
                <jndi-name>MSSQLDS</jndi-name>
                <connection-url>jdbc:sqlserver://yourSQLServerIP:1433/yourDatabase</connection-url>
                <driver-class>com.microsoft.jdbc.sqlserver.SQLServerDriver</driver-class>
                <user-name>yourUser</user-name>
                yourPwd
                <min-pool-size>2</min-pool-size>
                <max-pool-size>10</max-pool-size>
                </local-tx-datasource>



                Note: The name of the -ds.xml file should correspond to the jndi-name value.

                5. Add the datasource to the %JBOSS_DIST%\server\default\conf\standardjbosscmp-jdbc.xml file. Just the and <datasource-mapping> elements should be sufficient.

                This is what i used:

                MSSQLDS
                <datasource-mapping>MS SQLSERVER</datasource-mapping>

                6. Do the same as in step 5 in the %JBOSS_DIST%\server\default\conf\standardjaws.xml file.



                Now in your code you can access the Connection pool like so :

                Context ctx = new InitialContext();
                DataSource ds = (DataSource)ctx.lookup("java:/MSSQLDS");
                Connection con = ds.getConnection();
                ......

                or

                If you want to use direct JDBC access :

                Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
                Connection con = DriverManager.getConnection("jdbc:microsoft:sqlserver://yourSQLServerIP:1433;DatabaseName=yourDB;User=yourUser;Password=yourPwd");
                .......

                If you want do EJB you are on your own, haven't tried as yet.

                This is just what worked for me after a bit of trial and error today

                JBOSS/SQLServer guru's feel free to correct this as necessary.

                • 5. Re: jboss3.2, sql server 2000
                  gerinjo

                  Thats it, thx.

                  Why does he throw a ClassNotFoundException, when the SQLDriver from M$ is in the mssqlserver.jar and this file is in the lib directory? Why the mssqlserver.jar file is not loaded by the classloader?

                  regards
                  gerinjo