cancel
Showing results for 
Search instead for 
Did you mean: 

ERROR:NameNotFoundException: Object not found in lookup of MYDB

Former Member
0 Kudos

NW 7.0 SP3

I have defined a datasource MYDB by VA,and it tests OK.

I wonder about how to use it in J2EE project or in WebDynpro Project.

I created a J2EE project ,in the Web Model ,i new a class Test:

public static Connection myconn(){

......

Context ctx = new InitialContext();

Connection conn = null;

DataSource dataSource = null;

dataSource = (DataSource) ctx.lookup("MYDB");

conn = dataSource.getConnection();

return conn;

......

}

then in webcontent ,I new a JSP page:

<%

Connection conn = com.Test.myconn();

java.sql.Statement st = conn.createStatement();

String str = "select * from TMP_NAME";

ResultSet rs = st.executeQuery(str);

rs.next();

String str1 = rs.getString(1);

.....

%>

after build and deploy the *.ear,the server returns an error:

com.sap.engine.services.jndi.persistent.exceptions.NameNotFoundException: Object not found in lookup of MYDB.

Now I do not know anything else should I do,such as create a reference,and so on.

Thanks for you all help!

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Try the code as below:

DataSource ds = (DataSource) context.lookup("java:comp/env/jdbc/MYDB")

Go through the below help link:

http://help.sap.com/saphelp_nw2004s/helpdata/en/82/fdbf2085f65f43a71e755fc904478d/content.htm

Go through the below thread for more info:

Regards,

Charan

Answers (0)