5 Replies Latest reply on Nov 5, 2004 7:19 AM by lviz

    Jboss - MS SQLSERVER2000 configuration problem

    asite

      I am configuring our application on joss-3.2.5.
      We are using Ms Sql database.
      I have done up to following steps for configuration of Jdbc.

      1)copy msbase.jar,msutil.jar,mssqlserver.jar from Microsoft SQL Server 2000 Driver for JDBC\lib to
      C:\jboss-3.2.5\jboss-3.2.5\server\default\lib dir.
      2)Enter following detail in mssql-ds.xml file and copy it in C:\jboss-3.2.5\jboss-3.2.5\server\default\deploy dir.


      <local-tx-datasource>
      <jndi-name>dmsdb</jndi-name>
      <connection-url>jdbc:microsoft:sqlserver://databaseserv:1433;DatabaseName=dmsdb</connection-url>
      <driver-class>com.microsoft.jdbc.sqlserver.SQLServerDriver</driver-class>
      <user-name>sa</user-name>
      5q154
      <!-- sql to call when connection is created -->
      <new-connection-sql>SELECT COUNT(*) FROM sysusers WHERE 1 = -1</new-connection-sql>
      <max-pool-size>2147483647</max-pool-size>
      <idle-timeout-minutes>20</idle-timeout-minutes>

      </local-tx-datasource>


      3. I have modified the files from \jboss\server\default\config directory

      a) standardjaws.xml

      java:/dmsdb

      <type-mapping>MS SQLSERVER2000</type-mapping>
      false

      b) standardjbosscmp-jdbc.xml


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

      4. I have added the following xml info in login-config.xml file from \jboss\server\default\config

      <application-policy name = "MSSQLDbRealm">

      <login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule" flag = "required">
      <module-option name = "principal">sa</module-option>
      <module-option name = "userName">sa</module-option>
      <module-option name = "password">sa</module-option>
      <module-option name = "managedConnectionFactoryName">jboss.jca:service=XaTxCM,name=dmsdb</module-option>
      </login-module>

      </application-policy>

      5. now i am gettin connection by lookup in jndi tree

      ctx = new InitialContext();
      DataSource ds = (DataSource)ctx.lookup("dmsdb");
      now i am getting error message like this

      An error was encountered whilst connecting to the database. Please try again later..An
      error was encountered whilst connecting to the database. Please try again later.
      .dmsdb not bound

        • 1. Re: Jboss - MS SQLSERVER2000 configuration problem
          jboss_oops

          HI Asite,
          Did u get any response or solution on how to remove this error. I am also facing the same problem.
          If you have the soln plz post this as a reply to this message..
          thanx :)

          • 2. Re: Jboss - MS SQLSERVER2000 configuration problem
            asite

            HI!
            This is mehul savalia from Asite Solutions.

            now i am not getting the above problem.
            Please follow the steps in addtion to the jars stettings.
            1.Entery in MS-SQL DS


            <local-tx-datasource>
            <jndi-name>dmsdb</jndi-name>
            <connection-url>jdbc:microsoft:sqlserver://servname:1433;;ServerName=servername;PortNumber=1433;DatabaseName=databasename;User=sa;Password=password;SelectMethod=cursor</connection-url>

            <driver-class>com.microsoft.jdbc.sqlserver.SQLServerDriver</driver-class>

            <user-name>sa</user-name>
            5q154
            <prepared-statement-cache-size>50</prepared-statement-cache-size>

            <new-connection-sql>SELECT COUNT(*) FROM sysusers WHERE 1 = -1</new-connection-sql>
            <!-- sql to call when connection is created

            sql to call on an existing pooled connection when it is obtained from pool
            <check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
            -->
            <min-pool-size>25</min-pool-size>
            <max-pool-size>31000</max-pool-size>
            <idle-timeout-minutes>15</idle-timeout-minutes>
            <track-statements>false</track-statements>

            </local-tx-datasource>




            2. I have modified the files from \jboss\server\default\config directory

            a) standardjaws.xml

            java:/dmsdb

            <type-mapping>MS SQLSERVER2000</type-mapping>
            false

            b) standardjbosscmp-jdbc.xml


            java:/dmsdb
            <datasource-mapping>MS SQLSERVER2000</datasource-mapping>
            3. I have added the following xml info in login-config.xml file from \jboss\server\default\config

            <application-policy name = "MSSQLDbRealm">

            <login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule" flag = "required">
            <module-option name = "principal">sa</module-option>
            <module-option name = "userName">sa</module-option>
            <module-option name = "password">5q154</module-option>
            <module-option name = "managedConnectionFactoryName">jboss.jca:service=XaTxCM,name=dmsdb</module-option>
            </login-module>

            </application-policy>



            4 download msvcp71.dll and msvcr71.dll and copy it in system32 folder of window dir.


            Hope that it works for you.

            • 3. Re: Jboss - MS SQLSERVER2000 configuration problem
              asite

              one more thing when u do the lookup use

              java:/datasource name
              in my case it is

              java:/dmsdb

              • 4. Re: Jboss - MS SQLSERVER2000 configuration problem
                jboss_oops

                Hi I am also trying to connect to MS SQL Server 2000. I am running JBOSS 3.2.4
                My Client code is not able to do the JNDI MApping..
                Here Below I am attaching the code which I have in my client code.

                import javax.naming.*;
                import javax.sql.*;
                import java.sql.*;
                import java.io.*;
                import java.util.*;

                class TestJdbcJBoss
                {
                public static void main(String[] args) throws SQLException,IOException,ClassNotFoundException,NamingException
                {
                Hashtable ht=new Hashtable();
                ht.put(InitialContext.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
                ht.put(InitialContext.PROVIDER_URL,"jnp://localhost:1099");
                InitialContext ic=new InitialContext(ht);
                if(ic!=null)
                System.out.println("success11");
                DataSource ds=(DataSource)ic.lookup("java:/MSSQLDS");
                Connection conn = ds.getConnection();
                Statement st=conn.createStatement();
                ResultSet rs=st.executeQuery("select * from testbd");
                if(rs!=null)
                System.out.println("sucess");
                while(rs.next())
                {
                System.out.println(rs.getInt("test"));
                }
                }
                }

                This the error I am getting when I run my code
                success11
                Exception in thread "main" javax.naming.NameNotFoundException: MSSQLDS not bound
                at org.jnp.server.NamingServer.getBinding(NamingServer.java:495)
                at org.jnp.server.NamingServer.getBinding(NamingServer.java:503)
                at org.jnp.server.NamingServer.getObject(NamingServer.java:509)
                at org.jnp.server.NamingServer.lookup(NamingServer.java:282)
                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 sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
                at sun.rmi.transport.Transport$1.run(Transport.java:148)
                at java.security.AccessController.doPrivileged(Native Method)
                at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
                at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
                at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
                at java.lang.Thread.run(Thread.java:536)
                at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
                at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
                at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133)
                at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
                at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:528)
                at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:507)
                at javax.naming.InitialContext.lookup(InitialContext.java:347)
                at TestJdbcJBoss.main(TestJdbcJBoss.java:17)
                I have done all the settings and configuration in JBOSS has given in the below Link
                http://www.onjava.com/pub/a/onjava/2004/02/25/jbossjdbc.html


                Please guide me where I am doing wrong..
                what all additional changes I have to do?
                Please do reply
                thanks :)

                I also tried now that way you have suggested in your Previous asite mail.
                But I have not downloaded msvcp71.dll and msvcr71.dll..
                why do we need them??

                That too is giving the same error.
                What do u suggest to do?

                • 5. Re: Jboss - MS SQLSERVER2000 configuration problem
                  lviz

                  hi
                  here is our mssql-ds.xml

                  <datasources>
                   <local-tx-datasource>
                   <jndi-name>MSSQLDS</jndi-name>
                   <connection-url>jdbc:microsoft:sqlserver://sqlsrv.domain.me:1433;DatabaseName=db;SelectMethod=Cursor</connection-url>
                   <driver-class>com.microsoft.jdbc.sqlserver.SQLServerDriver</driver-class>
                   <user-name>user</user-name>
                   <password>pass</password>
                   <!-- sql to call when connection is created
                   <new-connection-sql>some arbitrary sql</new-connection-sql>
                   -->
                  
                   <!-- sql to call on an existing pooled connection when it is obtained from pool
                   <check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
                   -->
                   <min-pool-size>0</min-pool-size>
                   <max-pool-size>10</max-pool-size>
                   <blocking-timeout-millis>5000</blocking-timeout-millis>
                   <idle-timeout-minutes>5</idle-timeout-minutes>
                  
                   </local-tx-datasource>
                  
                  </datasources>
                  


                  cheers
                  L