9 Replies Latest reply on Oct 10, 2007 8:09 AM by jaikiran

    Configure JBoss to connect to multi database on multi machin

    changemylife

      Hi all!

      I have three machine (A, B, C).
      I have installed JBoss server on machine A.
      On B, I have installed MySQL. On C, I have installed Oracle.


      How I can configure JBoss server to when JBoss start, it can simultaneous connect to both of my database (MySQL and Oracle).

      I also try follow: On A, I create two hsqldb-ds.xml and oracledb-ds.xml (inside \server\default\deploy) but not effect !

      And when install JBoss, I choosen "Local" on the DataSource Configuration part.


      Have some ideas about this problem ? Guide to me or show me some documents to solve my problem.

      Thanks.

      Catania.

        • 1. Re: Configure JBoss to connect to multi database on multi ma
          jaikiran

          Creating the datasource files (-ds.xml) is the correct thing. When you say, it does take effect, what exactly happens? Do you see any exceptions? Also, can you post the contents of those 2 ds.xml files? (Please remember to enclose the contents the < code> block, by using the Code button in the message window. That will help in retaining the xml content).

          • 2. Re: Configure JBoss to connect to multi database on multi ma
            changemylife

            I use jboss-4.0.5.GA, EJB 3.0 and WinXP.
            On B and C, I installed MySQL.
            On A, inside \server\default\deploy, I have two file: remote1-ds.xml and remote2-ds.xml.
            remote1-ds.xml:

            <datasources>
             <local-tx-datasource>
             <jndi-name>MySqlDS</jndi-name>
             <connection-url>jdbc:mysql://computerB/Bdatabase</connection-url>
             <driver-class>com.mysql.jdbc.Driver</driver-class>
             <user-name>pc6</user-name>
             <password>pc6</password>
             <min-pool-size>5</min-pool-size>
             <max-pool-size>20</max-pool-size>
             <metadata>
             <type-mapping>mySQL</type-mapping>
             </metadata>
             </local-tx-datasource>
            </datasources>


            remote2-ds.xml:
            <datasources>
             <local-tx-datasource>
             <jndi-name>MySqlDS</jndi-name>
             <connection-url>jdbc:mysql://computerC/Cdatabase</connection-url>
             <driver-class>com.mysql.jdbc.Driver</driver-class>
             <user-name>pc6</user-name>
             <password>pc666</password>
             <min-pool-size>5</min-pool-size>
             <max-pool-size>20</max-pool-size>
             <metadata>
             <type-mapping>mySQL</type-mapping>
             </metadata>
             </local-tx-datasource>
            </datasources>


            When, I install JBoss on A machine, I choosen "Local" on the DataSource Configuration part. When JBoss start, I received some error:
            --- Incompletely deployed packages ---
            org.jboss.deployment.DeploymentInfo@2af98d73 { url=file:/C:/Program Files/jboss-
            4.0.5.GA/server/default/deploy/remote2-ds.xml }
             deployer: org.jboss.deployment.XSLSubDeployer@1d5b883
             status: Deployment FAILED reason: Trying to install an already registered mbea
            n: jboss.jca:service=LocalTxCM,name=MySqlDS
             state: FAILED
             watch: file:/C:/Program Files/jboss-4.0.5.GA/server/default/deploy/remote2-ds.
            xml
             altDD: null
             lastDeployed: 1191892567170
             lastModified: 1191892567139
             mbeans:


            After, I edited remote2-ds.xml from MySqlDS to MySqlDSTmp:
            <datasources>
             <local-tx-datasource>
             <jndi-name>MySqlDSTmp</jndi-name>
             <connection-url>jdbc:mysql://computerC/CDatabase</connection-url>
             <driver-class>com.mysql.jdbc.Driver</driver-class>
             <user-name>pc6</user-name>
             <password>pc666</password>
             <min-pool-size>5</min-pool-size>
             <max-pool-size>20</max-pool-size>
             <metadata>
             <type-mapping>mySQL</type-mapping>
             </metadata>
             </local-tx-datasource>
            </datasources>

            But when JBoss start, I don't received some errors but only BDatabase (MySqlDS) on B machine that JBoss can connect (it have some tables same as: hilosequences, jms_messages, ...). CDatabase on C machine is not. Although, JBoss show some infomations:
            08:44:01,255 INFO [WrapperDataSourceService] Bound ConnectionManager 'jboss.jca
            :service=DataSourceBinding,name=MySqlDSTmp' to JNDI name 'java:MySqlDSTmp'


            Guide to me, thanks.

            catania.

            • 3. Re: Configure JBoss to connect to multi database on multi ma
              jaikiran

              The datasource files that you posted look good to me. Also, the message

              08:44:01,255 INFO [WrapperDataSourceService] Bound ConnectionManager 'jboss.jca
              :service=DataSourceBinding,name=MySqlDSTmp' to JNDI name 'java:MySqlDSTmp'


              indicates that the datasource has been successfully bound to the JNDI name. When you say,

              But when JBoss start, I don't received some errors but only BDatabase (MySqlDS) on B machine that JBoss can connect (it have some tables same as: hilosequences, jms_messages, ...). CDatabase on C machine is not


              do you mean there are some errors when you are trying to operate with that datasource? How are you testing the datasources? Any piece of code where you are using these datasources?



              • 4. Re: Configure JBoss to connect to multi database on multi ma
                changemylife

                When JBoss start success, I open mySQL and I recognize that:

                On B machine, BDatabase have some tables: hilosequences, jms_messages, jms_roles, ....
                But on the C machine, CDatabase has not some tables as BDatabase. ---> Why CDatabase has not (if datasource has been successfully bound to the JNDI name)?

                I haven't operated with CDatabase ! But I think that if my datasources (include BDatabase and CDatabase) has been successfully bound to the JNDI name ---> Both of them must have some tables (as above). But only BDatabas have !

                Please guide to me why !

                Thanks.

                catania.


                • 5. Re: Configure JBoss to connect to multi database on multi ma
                  changemylife

                  Now, I write a entity named "Log_Entry"

                  @Entity
                  @Table(name = "log_records", schema = "CDatabase")
                  public class LogEntry implements Serializable {
                   private int id;
                   private Timestamp date;
                   public LogEntry(final Level lvl, final String msg) {
                   ....
                   }
                   @Id
                   @GeneratedValue(strategy = GenerationType.AUTO)
                   public int getId() {
                   return id;
                   }
                  ....

                  And I have persistent.xml:
                  <persistence>
                   <persistence-unit name="CDatabase">
                   <jta-data-source>java:/MySqlDSTmp</jta-data-source>
                   <properties>
                   <property name="hibernate.hbm2ddl.auto" value="update" />
                   <property name="hibernate.connection.driver_class">
                   com.mysql.jdbc.Driver
                   </property>
                   <property name="hibernate.default_schema">
                   CDatabase
                   </property>
                   <property name="hibernate.dialect">
                   org.hibernate.dialect.MySQLDialect
                   </property>
                   </properties>
                   </persistence-unit>
                  </persistence>

                  And I have some errors:
                  15:41:36,045 ERROR [SchemaUpdate] Unsuccessful: create table 456.log_records (id
                   integer not null auto_increment, message varchar(255), date datetime, level var
                  char(255), primary key (id))
                  15:41:36,061 ERROR [SchemaUpdate] Syntax error or access violation message from
                  server: "You have an error in your SQL syntax; check the manual that corresponds
                   to your MySQL server version for the right syntax to use near '456.log_records
                  (id integer not null auto_increment, message varchar(255), date ' at line 1"

                  But same as BDatabase, I deploy success (open MySql, and I see log_entry table!)! --> mean that JBoss server "not connect" to CDatabase (not effect).
                  have some ideas !

                  Thank.

                  Catania.

                  • 6. Re: Configure JBoss to connect to multi database on multi ma
                    jaikiran

                     

                    create table 456.log_records (id
                    integer not null auto_increment, message varchar(255), date datetime, level var
                    char(255), primary key (id))


                    Not sure why the 456 is getting prefixed to the table name. The configuration files that you posted did not contain this 456.

                    • 7. Re: Configure JBoss to connect to multi database on multi ma
                      changemylife

                      Oh! sorry. Not

                      456 .log_records
                      . It is :
                      15:41:36,045 ERROR [SchemaUpdate] Unsuccessful: create table CDatabase .log_records (id
                       integer not null auto_increment, message varchar(255), date datetime, level var
                      char(255), primary key (id))
                      15:41:36,061 ERROR [SchemaUpdate] Syntax error or access violation message from
                      server: "You have an error in your SQL syntax; check the manual that corresponds
                       to your MySQL server version for the right syntax to use near 'CDatabase.log_records
                      (id integer not null auto_increment, message varchar(255), date ' at line 1"


                      • 8. Re: Configure JBoss to connect to multi database on multi ma
                        changemylife

                        Today, I tried and success!

                        I recognized that:

                        1. Inside my Log_Entry entity has id filed and I edit to idMess
                        2. When I create the new schema in MySql, not begin a number (ex: not 2xxx, it should begin with character axxx).


                        Thank you jaikiran very much! Your helps are very useful for me.

                        I come from Vietnam. In Vietnam, I don't show The JBoss Organize that I can learn to get The JBoss Certificated ! Can you have ideas about it ?

                        Thank again.

                        Catania.

                        • 9. Re: Configure JBoss to connect to multi database on multi ma
                          jaikiran

                           

                          "catania" wrote:
                          In Vietnam, I don't show The JBoss Organize that I can learn to get The JBoss Certificated ! Can you have ideas about it ?



                          Sorry, i don't have much ideas about JBoss certifications.