This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Five Lines of Code and have Christian Clausen on-line!
See this thread for details.
Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

problem to Access database using JNDI name with Postgres

 
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i use JNDI name for getting Datasource using java:comp/jdbc/env/(jndiname)
however i connat get connectin object error is no connection

i use below coding in tomcat /conf/server.xml

<Context path="/JEE" docBase="JEE"
debug="5" reloadable="true" crossContext="true">
<Resource name="jdbc/LyricNote" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="postgres" password="" driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://localhost/struts"/>


</Context>

</Host>

i trying to get datasource my program


DataSource ds = (DataSource) ctx.lookup(java:comp/env/jdbc/LyricNote);
Connection con = ds.getConnection();

please help me!!
 
Bartender
Posts: 2658
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

however i connat get connectin object error is no connection

Can you share the real, complete error message?

One of these two has to be wrong:
In the top of your post you say: jdbc/env/(jndiname)
Further on you say: env/jdbc/LyricNote

Regards, Jan
[ September 08, 2007: Message edited by: Jan Cumps ]
 
Hey! You're stepping on my hand! Help me tiny ad!
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic