I am trying to connect hana database using java code as follow
try {
Class.forName("com.sap.db.jdbc.Driver");
String url = "jdbc:sap://host:30015/?";
String user = "myuser";
String password = "password";
System.out.println("try to connect to HANA !");
Connection cn = java.sql.DriverManager.getConnection(url, user, password);
System.out.println("Connection to HANA successful!");
ResultSet rs = cn.createStatement().executeQuery("select * from LIVE2.Connections");
rs.next();
System.out.println(rs.getInt(1));
} catch (Exception e) {
e.printStackTrace();
}
Connection is established successfully. And following exception occurs
com.sap.db.jdbc.exceptions.JDBCDriverException: SAP DBTech JDBC: [259] (at 20): invalid table name: Could not find table/view CONNECTIONS in schema LIVE2: line 1 col 21 (at pos 20)
at com.sap.db.jdbc.exceptions.SQLExceptionSapDB.createException(SQLExceptionSapDB.java:345)
at com.sap.db.jdbc.exceptions.SQLExceptionSapDB.generateDatabaseException(SQLExceptionSapDB.java:176)
at com.sap.db.jdbc.packet.ReplyPacket.buildExceptionChain(ReplyPacket.java:102)
at com.sap.db.jdbc.ConnectionSapDB.execute(ConnectionSapDB.java:1033)
at com.sap.db.jdbc.ConnectionSapDB.execute(ConnectionSapDB.java:823)
While when i connect using hana studio, Connections table exist in Live2 schema.
Any suggestion what's going wrong?
Thanks