Skip to Content
Aug 30, 2018 at 09:19 PM

Can't connect to HANA database inside SCP using Java.



I've spent my whole day trying to find out the root cause of an issue, and I truly believe you can help me on it!

I have a Java application which uses Spring and Hibernate to connect to a HANA database. I'm running it inside SCP, and have configured a binding of my application to my database:

This is how I have configured the JNDI lookup inside my application:

Spring configuration file:


@Bean@Resource(name = "jdbc/DefaultDB")

public DataSource dataSource() throws GeneralException { 
  try {      
       final JndiDataSourceLookup dsLookup = new JndiDataSourceLookup();           dsLookup.setResourceRef(true);      
       DataSource dataSource = dsLookup.getDataSource("java:comp/env/jdbc/DefaultDB");      
       return dataSource;   
      } catch (Exception e) {      
              String errorDetails = "Error loading datasource (dev,qa,prod profile) - " + SpringConfiguration.class.getName();      
               logger.error(errorDetails, e); 
                throw new GeneralException(errorDetails, e);  


<?xml version="1.0" encoding="UTF-8"?>

<web-app xmlns:xsi=""xmlns=""xsi:schemaLocation=""id="WebApp_ID" version="3.1">   

    <res-ref-name>jdbc/DefaultDB </res-ref-name>        
    <res-type>javax.sql.DataSource </res-type>   



<?xml version="1.0" encoding="UTF-8"?>

<Context  path="">    

<Resource name="jdbc/DefaultDB"auth="Container"type="javax.sql.DataSource"factory=""/>    

<ResourceLink name="jdbc/DefaultDB"global="jdbc/DefaultDB"type="javax.sql.DataSource" />


When I try to run it on SCP, i keep getting this error:

org.springframework.jdbc.datasource.lookup.DataSourceLookupFailureException: Failed to look up JNDI DataSource with name 'java:comp/env/jdbc/DefaultDB'; nested exception is javax.naming.NameNotFoundException: Name [jdbc/DefaultDB] is not bound in this Context. Unable to find [jdbc].

Do someone have some idea of what might be happening? I'm really running out of options here.


tp.png (7.2 kB)