1

I tried following the instructions mentioned here to add a driver for the SAP HANA database. The driver is available as a jar file, and had been added to the pom.xml:

 <dependency>
        <groupId>com.sap.db.jdbc</groupId>
        <artifactId>ngdbc</artifactId>
        <version>1.96.0</version>
    </dependency>

My application properties was as follows:

spring.jpa.hibernate.ddl-auto=create
spring.datasource.url=jdbc:sap://<YOUR SAP HANA IP>:host
spring.datasource.username=sap_hana_user
spring.datasource.password=sap_hana_password
spring.datasource.driver-class-name=com.sap.db.jdbc.Driver

However, that didn't work, and I was still getting the error message:

Cannot determine embedded database driver class for database type NONE.

What did work, was adding the Datasource programmatically, as mentioned here, and removing the application.resources file. So, finally, my Application.java looks like:

@SpringBootApplication
public class Application extends SpringBootServletInitializer
{
    @Bean
    @Primary
    public DataSource dataSource()
    {
        return DataSourceBuilder.create().username("user_name_sap_hana").password("password_sap_hana").url("jdbc:sap://<YOUR SAP HANA IP>:port").driverClassName("com.sap.db.jdbc.Driver").build();//https://stackoverflow.com/a/28822145/1243462 ; https://stackoverflow.com/a/1336965/1243462
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application)
    {
        return application.sources(Application.class);
    }

    public static void main(String[] args)
    {
        SpringApplication.run(Application.class, args);
    }
}

Could someone please explain what I did wrong? The first method did not mention having to do anything besides enter these details in application.resources.

shikharraje
  • 127
  • 1
  • 17
  • 1
    Suppose 'spring.datasource.driver-class-name' should be in 'application.properties' – Ilya Bystrov Aug 01 '17 at 12:24
  • Whoops, sorry. That was a typo in copy-pasting the code from Eclipse to my browser. Fixed it. But, even including the driver tag didn't work. – shikharraje Aug 01 '17 at 12:35
  • 1
    `spring.datasource.driver-class-name:com.sap.db.jdbc.Driver` looks wrong, should be -> `spring.datasource.driver-class-name=com.sap.db.jdbc.Driver` – gmaslowski Aug 01 '17 at 13:06
  • I just cannot catch a break :-/ . Okay, I edited the post with the copy paste from the commit right before I made the final `Application.java` class, with the Datasource. – shikharraje Aug 01 '17 at 13:37

0 Answers0