Showing results for 
Search instead for 
Did you mean: 

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

0 Kudos


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.

Accepted Solutions (0)

Answers (1)

Answers (1)

Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Victor,

Have you created the binding with the application runnning? If so, you have to restart the application so it can pick the binding during startup. Otherwise, the binding wont be available.

Please check your code with the following reference application.

I've just tested the sample above by replacing the postgresql driver dependency with the following in my pom.xml:


I also renamed the with so it picks the correct neo profile.

The app now opens correctly after deploying it, binding to my hana MDC and restarting it.

2018 08 31
Driver Name: HDB
Driver Version: 2.3.48-9bf9583a293e9fb8015c75991bf33038ae4f6bab
URL: jdbc:sap://
DB Name: HDB
Username: SYSTEM

The main page shows: