0

I need to deploy the Spring based Java Application in the HANA Cloud, i am not able to get the Data source giving error

2016 05 17 14:33:45#INFO#LJS_OUTPUT#Thread-11#14:33:45.128 [localhost-startStop-1] ERROR c.s.c.r.k.p.client.PersistenceDataSourceFactory - An exception occurred during rest communication with local config service: java.io.FileNotFoundException: http://localhost:20002/config/v1/services/persistence/jdbc/someothername|
2016 05 17 14:33:45#INFO#LJS_OUTPUT#Thread-11#14:33:45.129 [localhost-startStop-1] ERROR c.s.c.r.k.p.client.PersistenceDataSourceFactory - Retrieved persistence properties are null!|

Here is the Data source config details

Datasource binding and my web.xml as below

<resource-ref>
    <description>DB Connection</description>
    <res-ref-name>jdbc/someothername</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
</resource-ref>

and the i tried though JNDI Lookup

@Bean
  public DataSource getDataSource() {
  final JndiDataSourceLookup dsLookup = new JndiDataSourceLookup();
        dsLookup.setResourceRef(true);
        DataSource dataSource = dsLookup.getDataSource("jdbc/someothername");
        return dataSource;
  }

and i tired directly as

@Resource
DataSource dataSource

and also

@Resource("jdbc/someothername")
DataSource dataSource

Help me how to solve this issue

Thanks Chiranjeevi GK

1 Answer 1

2

Seeing that your database ID is named tutorial and that you use a HANA trial instance, I assume that you only need one data source / schema anyway.

In the HANA Cloud Platform documentation you can find two different approaches of how to get a database connection with tomcat 7 (Java Web SDK):

  1. Adding Application-Managed Persistence With JPA
  2. Adding Persistence With JDBC

The best way would be to have a look at these tutorials and to choose the way you prefer. The tutorials provide a lot of details.

My guess is, that the issue is caused because you gave your data source a custom name ("someothername"). If you only use one data source, you should always call it DefaultDB:

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

Then your JDBC lookup looks like this:

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

The data source in HANA Cloud Cockpit would then be called <default> (including the angled brackets). To do that, just delete your current data source binding and add a new one.

Data Source Binding Example

1
  • Yes i am using trail verson, i have to give the data as "jdbc/DefaultDB" May 18, 2016 at 7:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.