Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

How to use configured datasource

 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have set up a Postgres Datasource .

I now wanted to make use of it in my code .

Here is my configured datasource :: ( postgres-ds.xml )


After server startup I see the following in the logs ::


So looks like the Datasource is up and running

Questions ::
1 >
Can I use this datasource from a JSP to access the database ?
If yes can someone point me to a code example ?

2 >The above file is located here :: JBOSS_HOME\server\default\deploy

Does this mean that if I have two applications A & B - they can both access the same DB using this Datasource ?

3 >
Can I make the datasource more private ( as in only visible to my application ? )

Thanks ,
~satish
[ July 03, 2008: Message edited by: satish bodas ]
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Can I use this datasource from a JSP to access the database ?


Yes you can, but not recommended. JSPs are meant for just rendering the view

If yes can someone point me to a code example ?



Here's an example:




2 >The above file is located here :: JBOSS_HOME\server\default\deploy

Does this mean that if I have two applications A & B - they can both access the same DB using this Datasource ?



Yes, they can through JNDI lookup.

Can I make the datasource more private ( as in only visible to my application ? )



You can package the datasource within your application instead of placing it in the deploy folder. But once its available in the JNDI namespace, it can be looked up by other applications, provided they know the jndi-name of your datasource.
 
satish bodas
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the help - its working .

~satish
 
satish bodas
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the help - its working .


Yes you can, but not recommended. JSPs are meant for just rendering the view



Agreed - was trying out a quick example of db connectivity .

Thanks for helping out .

 
This parrot is no more. It has ceased to be. Now it's a tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic