Skip to Content
0
Former Member
Jun 29, 2009 at 09:19 AM

ERROR:NameNotFoundException: Object not found in lookup of MYDB

192 Views

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!