Foren
Retrieving data from database
Bakhtawar Khan, geändert vor 11 Jahren.
Retrieving data from database
New Member Beiträge: 14 Beitrittsdatum: 06.08.12 Neueste Beiträge
hiee All,
I want to retrieve data from database and display it on my portlet.Can someone tell me how to do that???
I want to retrieve data from database and display it on my portlet.Can someone tell me how to do that???
devaraj s, geändert vor 11 Jahren.
RE: Retrieving data from database
Regular Member Beiträge: 228 Beitrittsdatum: 21.05.12 Neueste BeiträgeBakhtawar Khan:
hiee All,
I want to retrieve data from database and display it on my portlet.Can someone tell me how to do that???
which databse you using for liferay.. Liferay by default will run on hsql database.. If you want to you can change to mysql or whichever database compaiatble to you..
Suppose you using mysql database means you create service.xml file by defining your db entities. once it done you build a service.
from persistance object you can add or retrieve the data from database.
xxxLocalServiceUtil Class and use there respective functions to get appropriate data.
Bakhtawar Khan, geändert vor 11 Jahren.
RE: Retrieving data from database
New Member Beiträge: 14 Beitrittsdatum: 06.08.12 Neueste Beiträge
I am using mysql.I am already done with building service but i am not getting the desired db on my portlet.
Hitoshi Ozawa, geändert vor 11 Jahren.
RE: Retrieving data from database
Liferay Legend Beiträge: 7942 Beitrittsdatum: 24.03.10 Neueste Beiträge
When you build your service there should have been xxxxLocalServiceUtil class generated. ( where xxx is hte name of your entity).
You just have to do a get() on the column you've defined.
How are you trying to display the data?
You just have to do a get() on the column you've defined.
How are you trying to display the data?
Bakhtawar Khan, geändert vor 11 Jahren.
RE: Retrieving data from database
New Member Beiträge: 14 Beitrittsdatum: 06.08.12 Neueste Beiträge
I have already done that....now i just want to display the content on another portlet.Any idea how to do that??
devaraj s, geändert vor 11 Jahren.
RE: Retrieving data from database
Regular Member Beiträge: 228 Beitrittsdatum: 21.05.12 Neueste BeiträgeBakhtawar Khan:
I have already done that....now i just want to display the content on another portlet.Any idea how to do that??
I think you have to use inetportlet communication concept.. Please correct me if this suggestion wrong ..
Bakhtawar Khan, geändert vor 11 Jahren.
RE: Retrieving data from database
New Member Beiträge: 14 Beitrittsdatum: 06.08.12 Neueste Beiträge
ya.....I am new to liferay so it will be better if u provide me steps to do that.
Rewati Raman, geändert vor 11 Jahren.
RE: Retrieving data from database
Junior Member Beiträge: 97 Beitrittsdatum: 24.02.12 Neueste BeiträgeBakhtawar Khan:
ya.....I am new to liferay so it will be better if u provide me steps to do that.
just take the jar from the lib of the portlet on which you had created the service.xml and paste it in the liferay-portal/tomcat/lib/ext then
write the following lines in your view.jsp page
here XXX means your entity Name Defined in service.xml
<%
int count = XXXLocalServiceUtil.getXXXsCount();
List<xxx> resultList = XXXLocalServiceUtil.getXXXs(0, count);
%>
<table border="1" width="80%">
<tbody><tr>
<th>ID</th>
<th>Name Of Canadidate </th>
<th>Phone</th>
<th>DOB</th>
</tr>
<%
for (XXX res : resultList) {
%>
<tr>
<td><%= res.getId() %></td>
<td><%= res.getName() %></td>
<td><%= res.getPhone() %></td>
<td><%= res.getDob() %></td>
</tr>
<%
}
%>
</tbody></table>
</xxx>
the above code will retreive the data
in the tablular format
it works for me every time
Regards,
Rewati Raman
devaraj s, geändert vor 11 Jahren.
RE: Retrieving data from database
Regular Member Beiträge: 228 Beitrittsdatum: 21.05.12 Neueste BeiträgeBakhtawar Khan:
ya.....I am new to liferay so it will be better if u provide me steps to do that.
refer this article you ill get an idea about IPC.
http://www.liferay.com/community/wiki/-/wiki/Main/Portlet+to+Portlet+Communication
Sagar A Vyas, geändert vor 11 Jahren.
RE: Retrieving data from database
Liferay Master Beiträge: 679 Beitrittsdatum: 17.04.09 Neueste BeiträgeBakhtawar Khan:
hiee All,
I want to retrieve data from database and display it on my portlet.Can someone tell me how to do that???
Hi Bakhtawar,
Please refer this
http://www.liferay.com/web/guest/community/forums/-/message_boards/view_message/15700837.
Thanks,
Sagar Vyas