cancel
Showing results for 
Search instead for 
Did you mean: 

"UnknownHost" exception while connecting to mysql from web dynpro

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi

I have created datasource in NWA since I am using C.E.

How do we test the datasource?

As I mentioned earlier in the driver that I have added to the datasource, the status is showing as "Unknown".

So how do I proceed?

Yes,The datasource name is correct in the code.

Thanks and regards,

Sumangala

Former Member
0 Kudos

Hi

I got solved my problem

The problem was solved by setting the Isolation Level property to Transaction Serializable in the datasource that I created in NWA.

Regards,

Sumangala