cancel
Showing results for 
Search instead for 
Did you mean: 

JDBC call to hana stored procedure with DML queries

Former Member
0 Kudos

Hi folks,

I was trying to call a hana stored procedure from JDBC. I was able execute stored procedures which contained simple data definition sql.

But when the stored procedure contained data manipulation sql, like update and insert, even though the jdbc class runs successfully, I don't see any changes in the hana stored tables that were supposed to be updated from the stored procedure itself.

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

		String user = "SYSTEM";
		String pwd = "******";
		//connect
	      Connection connection = null;
	      try {
	         connection = DriverManager.getConnection(
	            "jdbc:sap://localhost:30115/?autocommit=false",user,pwd);
	      } catch (SQLException e) {
	         System.err.println("Connection Failed. User/Passwd Error?");
	         return;
	      }
	      if (connection != null) {
	         try {
	            System.out.println("Connection to HANA successful!");
	        	CallableStatement stmt = connection.prepareCall("{CALL \"SYSTEM\".\"CALLJDBC\"()}");
	    			 stmt.executeUpdate();
		            System.out.println("executed!");
//		            stmt.close();
	    		} catch (SQLException e) {
	    			// TODO Auto-generated catch block
	    			e.printStackTrace();
	    		}
	     }
	   }

The called stored procedure contains just a bunch of insert statements with no IN or OUT parameters.

Is there a special way to execute sql insert/update statements from jdbc?

Any suggestions would be great!

Regards,

Devam

Accepted Solutions (1)

Accepted Solutions (1)

akshinde
Participant

Hi

In Your JDBC call you have autocommit property set as false , either set this as true if you do not want explicit commit after dml statement , and in case you want this as false then use explicit commit.

DriverManager.getConnection("jdbc:sap://localhost:30115/?autocommit=false",user,pwd);

thanks

Aniruddha Shinde

Former Member
0 Kudos

Thanks for pointing out.

Now I want to replace the "localhost" with ip address for access of the hana db from remote systems so as to call a procedure remotely. But when i use the new jdbc url with the ip address, I get a connection timeout.

The url looks like: "jdbc:sap://10.117.96.116:30065/?autocommit=true"

Am i missing out on some configurations?

Thanks,

Devam

Answers (0)