Skip to Content

No suitable driver found for jdbc:sap - Hana connection from PI udf

Hello Experts,

I am trying to connect Hana database from udf.


The code in NWDS is working fine and i can get the data from Hana table.

I use the same coed in a udf and exported the 'ngdbc.jar' as imported archive and try to access the Hana database.

I get the error
java.sql.SQLException: No suitable driver found for jdbc:sap://xxxxxxxxx:xxxxx/?autocommit=false


I tried to export the java code with the ngdbc.jar as runnabale jar also, but still the same error.

Can anyone give me some hint, how can i solve this?


Thanks in advance.

Regards,

Antony.

Add comment
10|10000 characters needed characters exceeded

  • Hello Experts,

    I have made some progress on this and now i have an error ' Exception:[java.lang.ExceptionInInitializerError] in class '.

    I do not thing this is related to the driver issue because, i tried to another naitve SQL jdbc connection with another udf, it was working for the first time through the udf.

    After that the udf gives the same exception. ' Exception:[java.lang.ExceptionInInitializerError] in class '.

    Can anyone give me a suggestion to solve this?

    Regards,

    Antony.

  • Get RSS Feed

2 Answers

  • Best Answer
    Feb 02, 2017 at 10:08 PM

    Hello All,

    As the way i tried to get the udf working was not succeed.

    So creating an adapter module was the best solution for me to put all the complex queries.

    1) I created a custom adapter module according to this tutorial below

    https://blogs.sap.com/2014/08/08/pi-74-adapter-module-creation-using-ejb-30/

    2) Added the hana jdbc driver(ngdbc.jar) and the native sql drivers through 'Add external JARs' .

    3) used the sample code below to connect the hana database.

    JDBC driver (ngdbc.jar) to your classpath.

    import java.sql.*;
    public class jdemo {
       public static void main(String[] argv) {
          Connection connection = null;
          try {                  
             connection = DriverManager.getConnection(
                "jdbc:sap://myhdb:30715/?autocommit=false",myname,mysecret);                  
          } catch (SQLException e) {
             System.err.println("Connection Failed. User/Passwd Error?");
             return;
          }
          if (connection != null) {
             try {
                System.out.println("Connection to HANA successful!");
                Statement stmt = connection.createStatement();
                ResultSet resultSet = stmt.executeQuery("Select 'hello world' from dummy");
                resultSet.next();
                String hello = resultSet.getString(1);
                System.out.println(hello);
           } catch (SQLException e) {
              System.err.println("Query failed!");
           }
         }
       }
    }
    
    

    Deploy the adapter module and call it in the receiver channel.

    It works just like that.

    Regards,

    Antony.

    Add comment
    10|10000 characters needed characters exceeded

    • Great to hear! Please go ahead and "accept" your own answer here, so the question will be marked as answered for others looking for this solution.

      Cheers,
      Matt

  • avatar image
    Former Member
    Jan 20, 2017 at 11:12 AM

    Hello Experts,

    I solved this issue by creating a custom adapter module.

    Want to know how?, do not hesitate to contact me.

    Regards,

    Antony.

    Add comment
    10|10000 characters needed characters exceeded