-
1. Re: .How can i change default databse Hypersonic to Mysql
vas_srinuin Apr 30, 2007 5:00 AM (in response to vas_srinuin)Steps to changing default Database Hypersonic to Mysql Database in Jboss
1.Download and set to the classpath the mysql driver (mysql-connector-java-5.0.4-bin.jar),
then copy this to [jboss-location]/server/default/lib directory.
2.Copty file named mysql-ds.xml([jboss-location]/ docs/examples/jca/) into the
[jboss-location]/server/default/deploy/ directory and edit IP Address,Driver Name,url ?.
<local-tx-datasource>
<jndi-name>MySqlDS</jndi-name>
<connection-url>jdbc:mysql://127.0.0.1:3306/test</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>root</user-name>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
<!-- 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>
-->
<!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
<type-mapping>mySQL</type-mapping>
</local-tx-datasource>
The important lines are the bolded ones, one is for the url used for connecting to the mysql server; if you didn't change the port it listens to, leave 3306. 'localhost' is the host where the mysql server is running, if is something other than this, change it to the ip to reflect it corectly. After the slash there's the name of the datatbase the driver would connect to by default (in my case, "OPA").
The <user-name> element is obviously for specifying the user name that should be used when trying to connect to the mysql server, and the element is for its corresponding password. Make sure u've created the user before testing the connection and have assigned that user with the rights for your above mentioned database. (see mysql manual for these operations :) )
3. copy the mysql-jdbc2-service.xml ([JbossLocation]\docs\examples\jms\mysql-jdbc2-service.xml) into D:/[JbossLocation]/server/default/deploy/jms/ and change the name (line no 58)DefaultDS to MySqlDS
4.copy the mysql-jdbc-state-service.xml into [JbossLocation]/server/default/deploy/jms/
and change the name(line no 15) DefaultDS to MySqlDS
note:if u did?t found the mysql-jdbc-state-service.xml go to [JbossLocation]/server/default/deploy/jms/ and reaname the hsqldb-jdbc-state-service.xml to the mysql-jdbc-state-service.xml -
2. Re: .How can i change default databse Hypersonic to Mysql
karim.baina May 15, 2013 12:30 PM (in response to vas_srinuin)Configuration :
AS : JBOSS 5.1
OS : Ubuntu 12.04.1 LTS
JDK : 1.6.0_27
Changing JBoss Database to Mysql :
1) In MySQL :
CREATE DATABASE jbossDB;
CREATE USER 'jboss'@'localhost' IDENTIFIED BY 'jboss';
GRANT ALL ON jbossDB.* TO jboss@localhost;
2) Download MySQL driver from http://dev.mysql.com/downloads/connector/j/, for instance mysql-connector-java-5.1.24.zip
3) Extract only mysql-connector-java-5.1.24-bin.jar
4) Copy mysql-connector-java-5.1.24-bin.jar to server/default/lib
5) Remove other drivers (ex. Hypersonic SQL h2-1.2.139.jar) from server/default/lib
6) Copy and adapt as follows JBOSS_HOME/docs/examples/jca/mysql-ds.xml to JBOSS_HOME/server/default/deploy/
It is preferred to rename MySqlDS ==> DefaultDS (it is simpler way to migrate form Hypersonic to Mysql)
<local-tx-datasource>
<jndi-name>DefaultDS</jndi-name>
<connection-url>jdbc:mysql://yourIP:yourPort/jbossDB</connection-url> <!-- ex yourIP = localhost and yourport = 3306 -->
<driver-class>com.mysql.jdbc.Driver</driver-class>
<min-pool-size>5</min-pool-size>
<max-pool-size>100</max-pool-size>
<idle-timeout-minutes>60</idle-timeout-minutes>
<security-domain>MySqlDbRealm</security-domain>
<!-- This is to -try- to avoid MySQL INNODB known deadlocks -->
<transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation> <!-- Without thi, you will also have a Warning -->
<!-- MySqlDbRealm is defined server/default/conf/login-config.xml -->
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
<metadata>
<type-mapping>mySQL</type-mapping>
</metadata>
</local-tx-datasource>
7) Remove other *-ds.xml files from JBOSS_HOME/server/default/deploy/*-ds.xml (ex. h2-ds.xml, hsqldb-ds.xml)
8) define MySqlDbRealm needed by DefaultDS in /home/baina/angel/BOS-5.10-JBoss-5.1.0.GA/server/default/conf/login-config.xml
<application-policy name = "MySqlDbRealm">
<authentication>
<login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule" flag = "required">
<module-option name = "principal">PRINCIPAL</module-option> <!-- ex. jboss -->
<module-option name = "userName">jboss</module-option> <!-- same db user defined before -->
<module-option name ="password">jboss</module-option> <!-- same db user passwd defined before -->
<!-- passwd can be crypted using login-module code="org.jboss.resource.security.SecureIdentityLoginModule"
and running
java -cp client/jboss-logging-spi.jar:lib/jbosssx.jar org.jboss.resource.security.SecureIdentityLoginModule LEPASSWORD
for more details : http://docs.jboss.org/jbosssecurity/docs/6.0/security_guide/html/Encrypting_Data_Source_Passwords.html
-->
<module-option name = "managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=DefaultDS</module-option>
</login-module>
</authentication>
</application-policy>
9) Copy and adapt as follows JBOSS_HOME/docs/examples/jms/mysql-persistence-service.xml TO JBOSS_HOME/server/default/deploy/messaging/mysqldb-persistence-service.xml
- Set CreateTablesOnStartup property to false Directely AFTER first succesful run of JBoss (on MySQL)
<attribute name="CreateTablesOnStartup">true</attribute> <!-- TWICE in mysqldb-persistence-service.xml -->
- Comment ChannelFactoryName property which deals with Clutering <!-- depends optional-attribute-name="ChannelFactoryName">jboss.jgroups:service=ChannelFactory</depends> -->
10) Comment InterceptorsFactory stuff in JBOSS_HOME/server/default/deploy/ejb3-interceptors-aop.xml
in order to avoid WARN [InterceptorsFactory] EJBTHREE-1246: Do not use InterceptorsFactory with a ManagedObjectAdvisor, InterceptorRegistry should be used via the bean container
<!--aspect name="InterceptorsFactory" factory="org.jboss.ejb3.interceptors.aop.InterceptorsFactory" scope="PER_INSTANCE"/-->
<!--advice name="invoke" aspect="InterceptorsFactory"/-->
11) JBOSS_HOME/bin/run.sh 1>output.txt &
12) you will remark that jbossDB is created through MySQL
Congratulations JBoss is persistent over MySQL.
-
3. Re: .How can i change default databse Hypersonic to Mysql
smarlow Apr 22, 2013 9:44 AM (in response to karim.baina)Or use AS7 (or later) which allows the default datasource to be configured for JPA deployments.