File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Name is not bound in this context Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Name is not bound in this context" Watch "Name is not bound in this context" New topic
Author

Name is not bound in this context

Swathi Prakash
Ranch Hand

Joined: Jan 18, 2005
Posts: 49
Hai ,,

please help me..i m using JNDI connection.. its working fine
this is working for inserting some records.. after some time i got the exception like this. i m new to this. plz help me

javax.naming.NameNotFoundException: Name java: is not bound in this Context
at org.apache.naming.NamingContext.lookup(NamingContext.java:768)
at org.apache.naming.NamingContext.lookup(NamingContext.java:151)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:136)


my connection code is :..

private static Context ctx;
public static java.sql.Connection getDBConnection() {
DataSource ds;
java.sql.Connection con;

try {
if(ctx==null) ctx=new InitialContext();
ds=(DataSource)ctx.lookup(InfrastructureLayer.DATASOURCENAME);

con=ds.getConnection();
} catch(NamingException ne) {
log("InfrastructureLayer.getConnection(): ERROR: Aborting file processing. while processing header thrown NamingException:"+ne);
ne.printStackTrace();
return null;
} catch(SQLException sqle) {
log("InfrastructureLayer.getConnection(): ERROR: Aborting file processing. while processing header thrown SQLException:"+sqle);
sqle.printStackTrace();
return null;
}

return con;
}
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
Let us have two pieces of information.

1. What is the value of InfrastructureLayer.DATASOURCENAME.

2. Post the contents of your deployment descriptor file.


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Swathi Prakash
Ranch Hand

Joined: Jan 18, 2005
Posts: 49
Hai Roger,

InfrastructureLayer.DATASOUCENAME = java:/comp/env/jdbc/mysql

whats thar deployment descriptor file where it is ???
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
Look for the ejb-jar.xml file. You should find an entry like this.

Swathi Prakash
Ranch Hand

Joined: Jan 18, 2005
Posts: 49
please help me
this is my descriptor file....
<Resource name="jdbc/mysql" auth="Container"
type="javax.sql.DataSource"/>

<ResourceParams name="jdbc/mysql">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>org.gjt.mm.mysql.Driver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://ananthan:3306/gotx?autoReconnect=true</value>
</parameter>
<parameter>
<name>username</name>
<value>root</value>
</parameter>
<parameter>
<name>password</name>
<value></value>
</parameter>
<parameter>
<name>maxActive</name>
<value>50</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>10</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>-1</value>
</parameter>
</ResourceParams>
Swathi Prakash
Ranch Hand

Joined: Jan 18, 2005
Posts: 49
pleas help me roger


THIS IS MY WEB.XML


<resource-ref>
<description>Web DB</description>
<res-ref-name>jdbc/mysql</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Name is not bound in this context
 
Similar Threads
Testing Database Connection
Database access, potential threading problem?
Problem using DataSource with core java app
naming.NameNotFoundException
How to get Connection through JNDI Datasource.