Skip to Content
0

SAP DBTech JDBC: [259] (at 14): invalid table name: Could not find table/view

Jul 25, 2017 at 10:55 AM

1.2k

avatar image
Former Member

Hi,

I am trying to connect HANA database using below java code,

try {
        Class.forName("com.sap.db.jdbc.Driver");
        String url = "jdbc:sap://myhost:39015/?";
        String user = "MYUSER";
        String password = "PASSWORD";
        System.out.println("Connecting to HANA..!");
        Connection cn = DriverManager.getConnection(url, user, password);
        System.out.println("Connection to HANA successful!");
        ResultSet rs = cn.createStatement().executeQuery("select * from \"TWEETS\"");
        rs.next();
        System.out.println(rs.getString(1));
    } catch (Exception e) {
        e.printStackTrace();
    }<br>

It connects HANA database successfully. But the following exception occurs.

com.sap.db.jdbc.exceptions.JDBCDriverException: SAP DBTech JDBC: [259] (at 14): invalid table name:  Could not find table/view TWEETS in schema SYSTEM: line 1 col 15 (at pos 14)
    at com.sap.db.jdbc.exceptions.SQLExceptionSapDB.createException(SQLExceptionSapDB.java:334)
    at com.sap.db.jdbc.exceptions.SQLExceptionSapDB.generateDatabaseException(SQLExceptionSapDB.java:165)
    at com.sap.db.jdbc.packet.ReplyPacket.buildExceptionChain(ReplyPacket.java:104)
    at com.sap.db.jdbc.ConnectionSapDB.execute(ConnectionSapDB.java:1110)
    at com.sap.db.jdbc.ConnectionSapDB.execute(ConnectionSapDB.java:854)
    at com.sap.db.jdbc.StatementSapDB.sendCommand(StatementSapDB.java:925)<br>

The TWEETS table exists under SYSTEM schema which I can able to query using HANA sudio (Eclipse plugin). But, I couldn't able to query the table using above java code.

Please help me to resolve this issue.

P.S : I tried below combinations as well to query TWEETS table. But no luck!

<code>1. "select * from TWEETS" 
2. "select * from SYSTEM.TWEETS"
3. "select * from \"TWEETS\" 
4. "select * from \"SYSTEM\".\"TWEETS\""
10 |10000 characters needed characters left characters exceeded

Hi,

two questions:

1) Are you using exactly the same user to connect to database from your application and through HANA studio?

2) Does this HANA system have more than one tenant database?

0

hi , MYUSER schema USER does he has access object privileges to SYSTEM Schema , You said you logged in using hanastudio , it works, did you login to hana studio with SYSTEM userid?

Thanks

Aniruddha

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

3 Answers

avatar image
Former Member Sep 14, 2017 at 05:05 AM
-1

Hi Michael,

you must include schema name on your query ex :

select * from YOUR_SCHEMA.\"TWEETS\"");
Show 1 Share
10 |10000 characters needed characters left characters exceeded

That's only required if the table is in a different schema than the current one. Per the description, the table is in the SYSTEM schema (bad practice!) and the connection is done with the SYSTEM user (worse practice!) so the name resolution does not require an explicit schema name in this case.

1
Anjali Chimnani
Jul 27, 2017 at 05:33 PM
0

Hi,

The case of the table name is important as well.

Can you check if in the system schema, the TWEETS table is all caps.

Or if possible can you post an image of the catalog from Studio.

Thank you.

Best Regards,

Anjali.

Share
10 |10000 characters needed characters left characters exceeded
ANIRUDDHA SHINDE Sep 14, 2017 at 02:23 PM
0

are you connecting to right system, this could be possible that the connection you are making to hana instance in java code is different than what you you are accessing in hana studio, this is one off possibility.

Share
10 |10000 characters needed characters left characters exceeded