Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem to Access database using JNDI name with Postgres

 
Kaleeswaran Karuppusamy
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!!
 
Jan Cumps
Bartender
Posts: 2598
12
C++ Linux Netbeans IDE
  • 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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic