4 Replies Latest reply on Apr 16, 2004 1:31 AM by dvk78

    Primary Key Generation for SQL2000 and JBoss 3.2.3

    rolf Newbie

      Hi guys,

      I was browsing this forum a lot regarding a solution for the Generated Primary Key Problem. I found a few for mysql solutions but nothing concrete for SQL2000. I tried to modify some MySql examples but always ran into problems. Is there anyone out there which could kindly provide me a sample for SQL2000 (Bean Code + the XML files).
      Any help would be very much appreciated

      Cheers
      Rolf

        • 1. Re: Primary Key Generation for SQL2000 and JBoss 3.2.3
          rolf Newbie

          Well I figured it out. I only needed to change the jbosscmp-jdbc file at the highlighted areas and also of course needed to define the field on the sql server to identity. That's all ... I'm impressed

          Cheers
          Rolf


          <?xml version="1.0" encoding="UTF-8"?>
          <!DOCTYPE jbosscmp-jdbc PUBLIC "-//JBoss//DTD JBOSSCMP-JDBC 3.2//EN" "http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_3_2.dtd">
          <jbosscmp-jdbc>
          <defaults>
          datasource java:/MSSQLDS /datasource //I know the <> are missing but otherwise you would see datasource.
          <datasource-mapping>MS SQLSERVER2000</datasource-mapping>
          </defaults>
          <enterprise-beans>
          <entity>
          <ejb-name>PerformanceMonitorEntity</ejb-name>
          <table-name>PerformanceMonitor</table-name>
          <cmp-field>
          <field-name>pK</field-name>
          <column-name>pK</column-name>
          <auto-increment/>
          </cmp-field>
          .
          .
          .
          .
          <cmp-field>
          <field-name>sourceHostName</field-name>
          <column-name>sourceHostName</column-name>
          </cmp-field>
          <entity-command name="mssql-fetch-key">
          </entity-command>
          </entity>
          </enterprise-beans>
          </jbosscmp-jdbc>


          • 2. Re: Primary Key Generation for SQL2000 and JBoss 3.2.3
            dvk78 Newbie

            Hi Rolf,

            Im a newbie and Ive a problem when i try to connect to a SQL2000 server from my bean in jboss. I get the error that the datasource is not bound.
            My jbosscmp-jdbc.xml is as follows :

            <jbosscmp-jdbc>

            MSSQLDS
            <datasource-mapping>MS SQLSERVER2000</datasource-mapping>
            <preferred-relation-mapping>foreign-key</preferred-relation-mapping>

            <enterprise-beans>

            <ejb-name>Plant</ejb-name>
            <table-name>PLANT</table-name>
            <cmp-field>
            <field-name>PLANTID</field-name>
            <column-name>PLANTID</column-name>
            </cmp-field>
            .
            .
            .
            .
            </enterprise-beans>
            </jbosscmp-jdbc>

            Am I missing something here. Im not sure if the tag value is fully qualified MSSQLDS.

            In the jboss-3.2.3\server\default\deploy\mssql-ds.xml I have,
            <jndi-name>MSSQLDS</jndi-name>
            <connection-url>jdbc:microsoft:sqlserver://servername:1433;DatabaseName=somedb</connection-url>
            <driver-class>com.microsoft.jdbc.sqlserver.SQLServerDriver</driver-class>

            Isnt that definition complete?
            What more do I need to do ?
            Any help would be greatly appreciated !

            Thanx.
            -Vinod

            • 3. Re: Primary Key Generation for SQL2000 and JBoss 3.2.3
              rolf Newbie

              Your mssqlds-ds.xml looks alright to me but I'm not sure about the port definition in yours after the server name. It works without it :)

              Cheers
              Rolf


              My mssqlds-ds.xml file:


              <local-tx-datasource>
              <jndi-name>MSSQLDS</jndi-name>
              <connection-url>jdbc:microsoft:sqlserver://vv_test1;DatabaseName=JBoss</connection-url>
              <driver-class>com.microsoft.jdbc.sqlserver.SQLServerDriver</driver-class>
              <user-name>sa</user-name>

              </local-tx-datasource>


              • 4. Re: Primary Key Generation for SQL2000 and JBoss 3.2.3
                dvk78 Newbie

                Hi,

                Fixed the problem. It was a problem with the namespace. I changed it to "java:/MSSQLDS" in my jbosscmp-jdbc.xml and got rid of the binding problem. SQLServer by default uses the port 1433. It was not a problem with the port.
                Things actually seem to work afterall :-) ...

                Looking at all the posts here n at other forums, I can understand the anguish that newbies like me go thru before they learn to configure JBoss.
                This forum is cool !