Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Is it possible to push data into non-liferay database using service.xml Pavan Gupta September 5, 2012 3:11 AM
RE: Is it possible to push data into non-liferay database using service.xml Christianto Sahat September 5, 2012 3:38 AM
RE: Is it possible to push data into non-liferay database using service.xml Pavan Gupta September 5, 2012 4:26 AM
RE: Is it possible to push data into non-liferay database using service.xml David H Nebinger September 5, 2012 5:00 AM
RE: Is it possible to push data into non-liferay database using service.xml Pavan Gupta September 7, 2012 12:07 AM
RE: Is it possible to push data into non-liferay database using service.xml Christianto Sahat September 7, 2012 12:18 AM
RE: Is it possible to push data into non-liferay database using service.xml a g October 8, 2012 2:30 AM
RE: Is it possible to push data into non-liferay database using service.xml Pavan Gupta October 8, 2012 3:24 AM
RE: Is it possible to push data into non-liferay database using service.xml a g October 8, 2012 3:43 AM
RE: Is it possible to push data into non-liferay database using service.xml a g October 8, 2012 4:05 AM
RE: Is it possible to push data into non-liferay database using service.xml Pavan Gupta October 8, 2012 4:27 AM
RE: Is it possible to push data into non-liferay database using service.xml a g October 8, 2012 4:54 AM
RE: Is it possible to push data into non-liferay database using service.xml a g October 8, 2012 5:36 AM
RE: Is it possible to push data into non-liferay database using service.xml Pavan Gupta October 8, 2012 6:21 AM
RE: Is it possible to push data into non-liferay database using service.xml a g October 9, 2012 12:18 AM
RE: Is it possible to push data into non-liferay database using service.xml a g October 8, 2012 4:28 AM
Pavan Gupta
Is it possible to push data into non-liferay database using service.xml
September 5, 2012 3:11 AM
Answer

Pavan Gupta

Rank: New Member

Posts: 16

Join Date: August 28, 2012

Recent Posts

Hi,

I am using liferay 6.1 to build a portlet. My requirement is to fetch data from non-liferay DB and update entries (push entries) back to non-liferay DB.

Using service builder tool, i am able to fetch data from non-LR DB but while pushing data back to non-LR DB, my portlet is trying to find table in LR DB and throwing table didn't exist exception.

So is it possible to push data back to Non-LR DB using service builder tool?

Thanks,
Pavan
Christianto Sahat
RE: Is it possible to push data into non-liferay database using service.xml
September 5, 2012 3:38 AM
Answer

Christianto Sahat

Rank: Regular Member

Posts: 176

Join Date: September 24, 2007

Recent Posts

I believe you just need to specify different datasource in service.xml, instead of Liferay's datasource ?
Pavan Gupta
RE: Is it possible to push data into non-liferay database using service.xml
September 5, 2012 4:26 AM
Answer

Pavan Gupta

Rank: New Member

Posts: 16

Join Date: August 28, 2012

Recent Posts

Hi Christianto,

Thanks for the response. Following entity info, i ahave specified in my service.xml content:


<entity name="Training" local-service="true" table="training"
remote-service="true" data-source="myDatasource">
<column name="userId" type="long" primary="true"></column>
<column name="firstName" type="String"></column>
<column name="lastName" type="String"></column>
</entity>


and non-LR DB info is present in ext-spring.xml file.

Fetching data is working fine but i am facing problem while pushing data to non-LR DB..

Thanks,
Pavan
David H Nebinger
RE: Is it possible to push data into non-liferay database using service.xml
September 5, 2012 5:00 AM
Answer

David H Nebinger

Community Moderator

Rank: Liferay Legend

Posts: 11113

Join Date: September 1, 2006

Recent Posts

Rather than writing about generalities that is anyone's guess, how about trying some specifics, i.e "when I call updateXxxx() it fails w/ this exception and here's the stack trace"...
Pavan Gupta
RE: Is it possible to push data into non-liferay database using service.xml
September 7, 2012 12:07 AM
Answer

Pavan Gupta

Rank: New Member

Posts: 16

Join Date: August 28, 2012

Recent Posts

@Christianto,
As i mentioned above, i have specified custom data-source "myDatasource" in service.xml file. Custom datasource info (connection url, username and passwd) is declared in ext-spring.xml file.

David H Nebinger:
Rather than writing about generalities that is anyone's guess, how about trying some specifics, i.e "when I call updateXxxx() it fails w/ this exception and here's the stack trace"...


@David, I am not getting any stack trace. it is printing only one line "ERROR [JDBCExceptionReporter:75] Table 'lportal.training' doesn't exist" on console.
i have a table name training in my Non-LR DB. and when i call addTraining(training modelObj), it is printing "lportal.training' doesn't exist" on console.
Christianto Sahat
RE: Is it possible to push data into non-liferay database using service.xml
September 7, 2012 12:18 AM
Answer

Christianto Sahat

Rank: Regular Member

Posts: 176

Join Date: September 24, 2007

Recent Posts

Seems that your configuration still using Liferay's datasource instead your own database.

Check out this link for your reference :
http://www.liferay.com/web/sten.martinez/blog/-/blogs/6831821
http://www.manning-sandbox.com/thread.jspa?threadID=40188
http://www.liferay.com/community/wiki/-/wiki/Main/Build+Services+Against+External+Database
http://www.liferay.com/community/wiki/-/wiki/Main/Connect+to+a+Database+with+Plugins+SDK

Another person that has successfully solve your problem :
http://www.liferay.com/community/forums/-/message_boards/message/12122420
a g
RE: Is it possible to push data into non-liferay database using service.xml
October 8, 2012 2:30 AM
Answer

a g

Rank: Expert

Posts: 409

Join Date: March 2, 2012

Recent Posts

Hi Pavan,

My requirement is like you only, i want to fetch the data from existing table.
i am using liferay6.1.0 CE and mysql 5.5

I created new portlet for view the Page.
please tell me what to define in service.xml for only fetch the data from my employee table.

using some condition.

(or)
you can tell only how to fetch the data from the employee table. using service.xml or any other possible way.

your information is very helpful for me. please send
Pavan Gupta
RE: Is it possible to push data into non-liferay database using service.xml
October 8, 2012 3:24 AM
Answer

Pavan Gupta

Rank: New Member

Posts: 16

Join Date: August 28, 2012

Recent Posts

Hi Anand,

service.xml only generates persistence layer code for you. If you want to fetch data from external DB then you need to create ext-spring.xml file and specify external Datasource info, hibernate session factory info in that config file. Put that config file in Meta-inf folder where other hibernate, spring related config files are present.

Here is my ext-spring.xml files content:

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" default-destroy-method="destroy" default-init-method="afterPropertiesSet" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id="myDatasource" lazy-init="true" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost/training?useUnicode=true"/>
<property name="username" value="root" />
<property name="password" value="root" />
</bean>
<bean id="liferayHibernateSessionFactory" class="com.liferay.portal.spring.hibernate.PortletHibernateConfiguration">
<property name="dataSource" ref="myDatasource" />
</bean>
</beans>

i guess, this will help u.

Thanks,
Pavan
a g
RE: Is it possible to push data into non-liferay database using service.xml
October 8, 2012 3:43 AM
Answer

a g

Rank: Expert

Posts: 409

Join Date: March 2, 2012

Recent Posts

i created ext-spring.xml now where i can place, I am using eclipse for Liferay and using portlet.
a g
RE: Is it possible to push data into non-liferay database using service.xml
October 8, 2012 4:05 AM
Answer

a g

Rank: Expert

Posts: 409

Join Date: March 2, 2012

Recent Posts

Hello Pavan,
i created ext-spring.xml and place into liferay-plugins-sdk-6.1.0-ce-ga1\portlets\empform-portlet\docroot\WEB-INF\src\META-INF\ext-spring.xml

Till now,

I created a new portlet using eclipse - liferay6.1.0 and it generate default some files.
Now I created ext-spring.xml.

Now, Please tell what is the next step I want to do.

Please guide me & already I am running out of time.

Regards
Anand
Pavan Gupta
RE: Is it possible to push data into non-liferay database using service.xml
October 8, 2012 4:27 AM
Answer

Pavan Gupta

Rank: New Member

Posts: 16

Join Date: August 28, 2012

Recent Posts

Hi Anand,

Define External DB table schema in service.xml and generate code using service builder.

this is my service.xml file content.

<entity name="Training" local-service="true" table="training"
remote-service="true" data-source="myDatasource">
<column name="userId" type="long" primary="true"></column>
<column name="firstName" type="String"></column>
<column name="lastName" type="String"></column>
</entity>

By using generated service, u should able to access external tables.

Thanks,
Pavan
a g
RE: Is it possible to push data into non-liferay database using service.xml
October 8, 2012 4:28 AM
Answer

a g

Rank: Expert

Posts: 409

Join Date: March 2, 2012

Recent Posts

In ext-spring.xml

<bean id="liferayHibernateSessionFactory" class="com.liferay.portal.spring.hibernate.PortletHibernateConfiguration">
<property name="dataSource" ref="myDatasource" />

com.liferay.portal.spring.hibernate.PortletHibernateConfiguration - I didn't create any class.

Please tell me what i need to do.
a g
RE: Is it possible to push data into non-liferay database using service.xml
October 8, 2012 4:54 AM
Answer

a g

Rank: Expert

Posts: 409

Join Date: March 2, 2012

Recent Posts

thank you pavan, I modify my service.xml and build services.

now how i fetch the record in view.jsp
a g
RE: Is it possible to push data into non-liferay database using service.xml
October 8, 2012 5:36 AM
Answer

a g

Rank: Expert

Posts: 409

Join Date: March 2, 2012

Recent Posts

which class i need to import to get the empid,employee name,...........etc

pavan send your input
Pavan Gupta
RE: Is it possible to push data into non-liferay database using service.xml
October 8, 2012 6:21 AM
Answer

Pavan Gupta

Rank: New Member

Posts: 16

Join Date: August 28, 2012

Recent Posts

Hi,

After generating persistence layer code, u must be having some utility class related to ur service. Use that utility class to fetch data from DB.

Thanks,
Pavan
a g
RE: Is it possible to push data into non-liferay database using service.xml
October 9, 2012 12:18 AM
Answer

a g

Rank: Expert

Posts: 409

Join Date: March 2, 2012

Recent Posts

Hi Paven,

I have attached Employee portlet file. I sent my all code. I have written view.jsp to call util class to fetch the record from the employee table.

Can you please correct me where I am doing wrong in view.jsp. Because in the persistance class set all the employee details using SOAP and other place using JSON.

so I got confuse how to get the employee table record. Please correct me. it will really help for me.
Attachments: Employee.zip (35.1k)