cancel
Showing results for 
Search instead for 
Did you mean: 

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

Former Member
0 Kudos

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\""
BJarkowski
Active Contributor
0 Kudos

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?

akshinde
Participant
0 Kudos

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

Accepted Solutions (0)

Answers (3)

Answers (3)

akshinde
Participant
0 Kudos

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.

Former Member
0 Kudos

Hi Michael,

you must include schema name on your query ex :

select * from YOUR_SCHEMA.\"TWEETS\"");
lbreddemann
Active Contributor

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.

Former Member
0 Kudos

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.