on 10-06-2008 6:48 AM
Hi
I am trying to connect to Mysql 5.0 database from web dynpro application.I am using NWDS 7.1.
I have followed this blog and created the datasource in NWA.
https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/8675
I have written the following code in my web dynpro application.
InitialContext ctx;
try{
ctx=new InitialContext();
DataSource ds=(DataSource)ctx.lookup("jdbc/dbconnect");
Connection conn=ds.getConnection();
wdComponentAPI.getMessageManager().reportSuccess("connected");
Statement stmt=conn.createStatement();
String query="select Col from TestTable";
ResultSet res=stmt.executeQuery(query);
while(res.next())
{
String str1=res.getString(1);
wdComponentAPI.getMessageManager().reportSuccess(str1);
}
}catch (Exception e) {
wdComponentAPI.getMessageManager().reportSuccess(e.getMessage());
// TODO: handle exception
}
But I m getting the following error as "UnknownHost exception"
I checked with the datasource created in NWA.Here in the Driver status it is showing the driver as unknown.
I have added the following driver.
mysql-connector-java-5.0.8-bin.jar
Any idea on how to solve this problem?
Do I need to add the driver in my application also.
Thanks in advance,
Sumangala
Hi,
Have you created a datasource in Visualadmin?
Was that tested and was it success full?
If you havent done this this could be your issue
make sure the following code is using the correct datasource
DataSource ds=(DataSource)ctx.lookup("jdbc/dbconnect");
Regards
Ayyapparaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.