Quantcast
Channel: It's all about Java and Liferay
Viewing all articles
Browse latest Browse all 12

Connecting to different database using Liferay Service Builder

$
0
0
Generally we guys used to connect with the liferay default Database.
We also have requirement that Client wants there Data on Separate Schema or Separate DB.
But In Liferay how we can connect with different DB?

Don't Worry guys your problem is now solved.

Just Follow some steps as below :-

1) In Service.xml define the datasource, session-factory,transcation-manager within the Entity Definition as follows:-


test



......
......



2) Create a new file ext-spring.xml under WEB-INF/src/META-INF dir.














































3) And one more thing don't forget, pointing to the new DB.
    So the portal-ext.properties will look like as below :-
jdbc.default.url=jdbc\:mysql\://localhost/lportal?useUnicode\=true&characterEncoding\=UTF-8&useFastDateParsing\=false
jdbc.default.driverClassName=com.mysql.jdbc.Driver
jdbc.default.username=root
jdbc.default.password=root

jdbc.test.driverClassName=com.mysql.jdbc.Driver
jdbc.test.url=jdbc:mysql://localhost/anotherDatabaseName?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
jdbc.test.username=root
jdbc.test.password=root

4) Final Step Build service with the command ant build-service.

Congratulations,Your work is done !!!!!!!!!!


Viewing all articles
Browse latest Browse all 12

Trending Articles