Fóruns

Início » Liferay Portal » English » 3. Development

Visualização combinada Visão plana Exibição em árvore
Tópicos [ Anterior | Próximo ]
toggle
Smilelws2010 lwz
Service Builder - and additional jdbc connection to database
12 de Junho de 2013 11:20
Resposta

Smilelws2010 lwz

Ranking: Regular Member

Mensagens: 160

Data de entrada: 16 de Dezembro de 2010

Mensagens recentes

HI

Can a liferay custom portlet built using service builder ( crud operation on database) use a separate jdbc connection also within the same portlet to talk to database?

Much appreciate if you can guide me.

Smile
Brian Scott Schupbach
RE: Service Builder - and additional jdbc connection to database
12 de Junho de 2013 12:12
Resposta

Brian Scott Schupbach

Ranking: Expert

Mensagens: 329

Data de entrada: 23 de Outubro de 2008

Mensagens recentes

In the META-INF folder of your portlet create a context.xml file and define the new connection.

Then to connect

1
2DataSource ds = (DataSource)envContext.lookup("jdbc/connectionInContextXML");
3            
4Connection  conn = ds.getConnection();
Smilelws2010 lwz
RE: Service Builder - and additional jdbc connection to database
12 de Junho de 2013 12:41
Resposta

Smilelws2010 lwz

Ranking: Regular Member

Mensagens: 160

Data de entrada: 16 de Dezembro de 2010

Mensagens recentes

Thanks Brian for the quick suggestion and reply.

And you can query the database from within your XXXserviceImpl class normally?

Best Regards,
SMile
Brian Scott Schupbach
RE: Service Builder - and additional jdbc connection to database
12 de Junho de 2013 12:44
Resposta

Brian Scott Schupbach

Ranking: Expert

Mensagens: 329

Data de entrada: 23 de Outubro de 2008

Mensagens recentes

Correct. You should try it out and if you have errors that you can't figure out, post the log in one of the forums. However, I think you'll find it's pretty easy to figure out.
Good luck
Smilelws2010 lwz
RE: Service Builder - and additional jdbc connection to database
18 de Junho de 2013 09:30
Resposta

Smilelws2010 lwz

Ranking: Regular Member

Mensagens: 160

Data de entrada: 16 de Dezembro de 2010

Mensagens recentes

Thanks Brian for the quick guidance

I could use the simple jdbc as well as jndi connection in addition to SB from the porlet.properties file. I did not have to make the context file under meta-inf. Is that a practice?

Thanks
Smile