wood burning stoves 2.0*
The moose likes JDBC and the fly likes OracleDatabaseMetaData.getColumns() returns an empty result set Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "OracleDatabaseMetaData.getColumns() returns an empty result set" Watch "OracleDatabaseMetaData.getColumns() returns an empty result set" New topic
Author

OracleDatabaseMetaData.getColumns() returns an empty result set

Doug Slattery
Ranch Hand

Joined: Sep 15, 2007
Posts: 294
Howdy Ranchers,

I've setup a dbunit unit test for some DAO's I worked on. I was using HSQL (which worked) and am moving it to Oracle 11g.

The data is loaded via dbunit's FlatXmlDataSetBuilder, Spring 2.5.6 LocalContainerEntityManagerFactoryBean and Hibernate 3.4 OracleDriver.

The database is setup using synonyms and I used dbunit's DabaseConfig.setProperty() method to set the table type to "SYNONYM". It was a bit of a struggle getting that figured out. I had to debug dbunit down into IMetadataHandler.getTables() to get that working.

I'm stuck now on the getColumns() problem and not sure what to look for. Google produced GRANT SELECT on the tables, but I'm able to do SELECTs from SQL Explorer in Eclipse. I'm not knowledgeable enough about SQL to know where the SELECT on table columns should be applied (if that is really the problem).

Anyone have any ideas?

Thanks,
- Doug

-- Nothing is impossible if ImPossible
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1121

Doug,
There are several properties related to synonyms that affect the behavior of Oracle's JDBC driver.
I suggest you experiment with them.
They are detailed in the javadoc for class oracle.jdbc.OracleConnection.
The javadoc is available for download from this page.

Good Luck,
Avi.
Doug Slattery
Ranch Hand

Joined: Sep 15, 2007
Posts: 294
Thanks for the tip Avi,

Unfortunately, oracle.jdbc.OracleConnection is not what I need. org.dbunit.ext.oracle.OracleConnection is what I am using.

Too bad that class doesn't have the synonym properties as the Oracle JDBC class.

Anyway, we've gone with an alternative approach that is working.

Take care,
- Doug

-- Nothing is impossible if ImPossible
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3703
    
    5

Doug Slattery wrote:Anyway, we've gone with an alternative approach that is working.


Could you share your approach in case others have similar issues?


My Blog: Down Home Country Coding with Scott Selikoff
Doug Slattery
Ranch Hand

Joined: Sep 15, 2007
Posts: 294

Could you share your approach in case others have similar issues?


Sure.

I was using org.dbunit.operation.DatabaseOperation.REFRESH.execute(connection, dataSet) in my base test class that gets extended by the unit tests to load the test data from an xml file. The xml file was created from a db export of a good test data set and could be used as is this way. It worked great with HSQL.

If the database is discovered by the class to be Oracle, it doesn't use that, and instead loads the test data via connection.createStatement().execute(<sql string>). The <sql string> is read from an sql file. The xml file data set was fairly small, so converting it to a bunch of inserts cost less than continuing to fight the other problem.

Thanks,
- Doug

-- Nothing is impossible if ImPossible
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: OracleDatabaseMetaData.getColumns() returns an empty result set
 
Similar Threads
Test Data Strategies
DBUnit question - NoSuchTableException
SetNull in a PreparedStatement
DbUnit and Hibernate hbm2ddl.auto, best practices...
Hibernate/JPA/PostGreSQL & hbm2ddl