2 Replies Latest reply on Aug 23, 2004 2:53 AM by asite

    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
          mbaptist

          Hi,


          Here is the Datasource definition we are using to connect to a MS-SQLServer 2000 from a Linux Jboss server:
          (replace jndi name and properties values with your own...)


          <local-tx-datasource>
          <jndi-name>jdbc/DSNAME</jndi-name>
          <connection-url>jdbc:microsoft:sqlserver://DBSERVER:xxxx;ServerName=DBSERVER;PortNumber=xxxx;DatabaseName=DBNAME;User=DBUSER;Password=DBUSERPWD;SelectMethod=cursor</connection-url>
          <driver-class>com.microsoft.jdbc.sqlserver.SQLServerDriver</driver-class>
          <user-name>DBUSER</user-name>
          DBUSERPWD
          <prepared-statement-cache-size>50</prepared-statement-cache-size>
          <min-pool-size>5</min-pool-size>
          <max-pool-size>50</max-pool-size>
          <idle-timeout-minutes>15</idle-timeout-minutes>
          <track-statements>false</track-statements>
          </local-tx-datasource>


          Here is also a piece of code:

          Context context = new InitialContext();
          Object ref_ms = context.lookup("java:/jdbc/DSNAME");
          DataSource ds_ms =
          (DataSource) PortableRemoteObject.narrow(ref_ms, DataSource.class);
          connection_ms = ds_ms.getConnection();

          ...

          prepStmt = connection_ms.prepareStatement(DbRequest);
          rs = prepStmt.executeQuery();

          ...

          rs.close();
          prepStmt.close();
          connection_ms.close();
          ...

          hope this will help you ;-)
          Br,

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

            Thanks Marc,
            I change my connection-url with the Yours .
            Now its working.
            Thanks.