Search code examples
oracle-databasedatabase-connectionresultsettablename

Set ResultSetMetaDataOptions for a connection object in C3P0 connection pool datasource for Oracle db


Has anybody been successful in retrieving the tablename from ResultSetMetaData via the getTableName() for Oracle database ?

All the online materials suggest to set ResultSetMetaDataOptions to "1", but it does not work.


Solution

  • As stated here Information about getTableName():

    Hi. Sorry to be the bearer of bad news, but Oracle's DBMS doesn't send the information about what table a column came from, so the oracle driver will never be able to implement that resultset metadata call. Most DBMSes don't either, and so you will see that 99% of all JDBC drivers will also not implement that call to return anything useful. Only Sybase, with their very latest driver and a specific optional DBMS configuration, have done it. It takes a change in the DBMS that most DBMS vendors will never bother to do.

    Edit: I tried below approach to set the parameter:

    java.util.Properties info = new java.util.Properties();
    info.put ("user", "scott");
    info.put ("password", "tiger");
    info.put ("ResultSetMetaDataOptions", "1");
    
    Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@myhost:1521:orcl", info);
    

    However, it didn't work - I was still unable to get the table name. This property is not on the list of possible properties which you can check here: Driver documentation. I was also unable to find any other way to set that property and get it to work.