Skip to Content
0

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

Jan 15, 2017 at 09:46 PM

629

avatar image

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.

10 |10000 characters needed characters left 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.

1
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Antony FERMINUS Feb 02, 2017 at 10:08 PM
1

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.

Show 1 Share
10 |10000 characters needed characters left 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

0
Francis Masscho Jan 20, 2017 at 11:12 AM
0

Hello Experts,

I solved this issue by creating a custom adapter module.

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

Regards,

Antony.

Show 4 Share
10 |10000 characters needed characters left characters exceeded

Francis,

As this is a community platform that is all about sharing knowledge, perhaps you could share some more details about your solution here for all to see?

Cheers,
Matt

1

Hi Matt,

In one comment my name is displayed as "Francis Masscho".

I do not knoww how?

Regards,

Antony.

0

You mean https://people.sap.com/francismasscho and https://people.sap.com/antony.ferminus are the same person? These are two different accounts.

0

Ok thanks. It was my clients S-user which was saved in the browser.

1