on 06-29-2009 10:19 AM
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!
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.