on 07-04-2017 11:03 AM
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
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);
thanksAniruddha Shinde
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.