cancel
Showing results for 
Search instead for 
Did you mean: 

Failed to get DataSource when named data source is bound to MDC DB

0 Kudos
1,770

Hi,

I created one Java application and deployed into my trial account. In web.xml. I add one resource reference for named data source "DefaultDB", after deployment, I bind this datasource DefaultDB to one MDC database(also trial instance) under the same account. In my code I used JNDI look-up to get the data source. I got error as below:

      java.sql.SQLException: Cannot create JDBC driver of class '' for connect URL 'null‘


code is as below:

try{

  InitialContext ctx = new InitialContext();

  DataSource ds2 = (DataSource) ctx.lookup("java:comp/env/jdbc/DefaultDB");

  return ds2;

  }catch(NamingException e){

  return null;

  }

From the exception, for non-cloud Java application, it can be solved by adding resource definition(driver class, URL, user and password" in server.xml. But my understanding is this part should be handled by HCP. From data source binding, HCP could manipulate the needed info to add the resource definition in server.xml.

Are there any additional setting should be done?

Thanks!

Patrick

View Entire Topic
xu_xiang
Advisor
Advisor
0 Kudos

Hi Patrick,

it looks like the data source binding doesn't setup correctly. The connection URL shouldn't be 'null'.

Please check Binding Databases and the samples for JPA/JDBC around the documentation also.

Regards

Xu