Skip to Content
author's profile photo Former Member
Former Member

JDBC Connection to SAP HANA on Linux systems

Hello everyone,

I have some trouble with the ngdbc.jar driver from the HANA client. This file is supposed to handle all JDBC connections to HANA. It's working perfectly in my Java application on Windows. On Linux I can start its inbuilt GUI via "java -jar ngdbc.jar" and it works there as well. But it is not working is when I run the same Java application on Linux and I'm wondering why? Maybe you can help.

Here is a part of the code:

Connection con = DriverManager.getConnection("jdbc:sap://" + servername + ":3" + instancename + "15/", username, password);

On Windows this works, on Linux no matter what I try either this exception is thrown:

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

Or this one:

java.sql.SQLException: No suitable driver

And "DriverManager.getDriver("jdbc:sap://")" returns no entries when running on Linux, but on Windows.

Hope somebody has worked with this driver in combination with Java and Linux already and can give a hint.

Thanks,

Markus

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Jan 17, 2014 at 06:30 AM

    Hello,

    Are you binaries for Linux from HANA client on windows?

    Thanks,

    Sunny

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 21, 2014 at 03:00 PM

    Hi Markus,

    have you tried including the jar file to the class search path?

    java -cp ngdbc.jar <your class files>

    That does work for me...

    Lars

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Markus,

      Good you have solve the problem, but it does not seem to work as it should !
      But I think this is related to IDE and it class loader.

      The JDBC 4 spec requires a driver to register itself when the class is loaded, and the class is loaded via Class.forName().

      In JDBC 4 the drivers are able to also loaded automatically just by being on the class path.

      DriverManager.registerDriver() manually is potentially dangerous since it actually causes the
      Driver to be registered twice. If your code requires you to deregister a Driver to prevent a memory leak then you would only end up deregistering it once and leave a second instance registered.

      The JDBC 4 DriverManager methods getConnection and getDrivers have been enhanced to
      support the Java Standard Edition Service Provider mechanism.
      JDBC 4.0 Drivers must include the file META-INF/services/java.sql.Driver.
      This file contains the name of the JDBC drivers implementation of java.sql.Driver.

      If you add Some small code like this to your sample it will show what driver is registered


      List drivers = Collections.list(DriverManager.getDrivers());
      for(int i=0;i<drivers.size();i++){
      Driver driver = (Driver)drivers.get(i);
      String driverName = driver.getClass().getName();
      System.out.println("Driver "+i+":::"+driverName);


      Will give you output as depend on what is loaded.
      Driver 0:::sun.jdbc.odbc.JdbcOdbcDriver
      Driver 1:::com.sap.db.jdbc.Driver


      Niclas

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.