留言板

Connecting to liferay database(mysql) without using service builder

Charmaine Rebollido,修改在14 年前。

Connecting to liferay database(mysql) without using service builder

Junior Member 帖子: 28 加入日期: 09-12-12 最近的帖子
Hello,

Can anyone help me find out how can I create a portlet that can automatically access mysql and liferay database without using a service builder?

Also, without manually indicating in an sql statement the username and password of mysql in the portlet. I am using jsp/jsf in developing portlets.

Generally what I want to do is a portlet that can be dynamically deployed to different liferay portals without having to set the values of the username and password being used by that portal in its database and without using service builder.

I hope someone can help me with this and if possible can provide a step by step tutorial.

Thanks in advance.
emoticon
thumbnail
Manish Kumar Gupta,修改在14 年前。

RE: Connecting to liferay database(mysql) without using service builder

Liferay Master 帖子: 535 加入日期: 08-5-16 最近的帖子
In your portlet, you can use com.liferay.portal.kernel.dao.jdbc.DataAccess API to get the connection and do whatever you want to do in your portlet.
Charmaine Rebollido,修改在14 年前。

RE: Connecting to liferay database(mysql) without using service builder

Junior Member 帖子: 28 加入日期: 09-12-12 最近的帖子
Hi Manish,

Thanks for your reply, can you provide an example on how to use it? Thanks
Vijay Peddareddy,修改在12 年前。

RE: Connecting to liferay database(mysql) without using service builder

New Member 帖子: 10 加入日期: 12-3-14 最近的帖子
Charmaine Rebollido:
Hi Manish,

Thanks for your reply, can you provide an example on how to use it? Thanks



Hi Manish,

I know this is too old post. But I've the same question Charmaine posted. Could you please help out with any example ?

Charmaine, If you already found any solution to this issue, please share.

Thanks a lot in advance.

Regards
Vijay Peddareddy.
thumbnail
Hitoshi Ozawa,修改在12 年前。

RE: Connecting to liferay database(mysql) without using service builder

Liferay Legend 帖子: 7942 加入日期: 10-3-24 最近的帖子
This is a very old thread. With the recent versions, it's possible to use dynamic query to execute your own sql command.
Vijay Peddareddy,修改在12 年前。

RE: Connecting to liferay database(mysql) without using service builder

New Member 帖子: 10 加入日期: 12-3-14 最近的帖子
Hitoshi Ozawa:
This is a very old thread. With the recent versions, it's possible to use dynamic query to execute your own sql command.



Hi Hitoshi,

Thanks a lot for your reply.

Below is my requirement. Could you please help on how to achieve this in (Liferay 6.1 + Tomcat 7) environment:

Our customers want to use liferay with the separate SCHEMA (in same database) for client overrides, in other words we want to implement a solution
where every customer will get his own SCHEMA for client specific data and keep the liferay data in liferay database only.

For example : Table X is created in Liferay schema for Client1 data; same Table X is created in MyData schema for this client1. In this case Portlet should get data from X table of MyData Schema.
Table Y is created in Liferay Schema for Client2 data. There's no schema for Client2. So, in this case Portlet should get data from Y table of Liferay Schema only.

Thant means, On load of Portlet, I should be able to switch to client specific SCHEMA dynamically if there is one for logged in user otherwise I should use Liferay database only.

I'm able to achieve this through Service Builder. But, every time new SCHEMA is added (OR) every time this Portlet is deployed on to new Client Platform, we need to touch service.xml to generate code for the new schema. I want to overcome this.

Is there any other way to achieve this dynamically with no code change ??

I hope you understand what's my requirement is. Please help how to achieve this.

Thanks a lot in advance.
Vijay Peddareddy.