[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - ClassCastException when calling DatabaseMetadatat functions

tonioinho do-not-reply at jboss.com
Wed Sep 10 10:31:05 EDT 2008


Hi,

Using JbossAS 4.2.2GA and Oracle 10g, I  access a DataSource through JNDI lookup.

Everything works fine until I try to call methods of DatabaseMetadata which return a ResultSet.



  |         InitialContext ic = new InitialContext();
  |         DataSource datasource = (DataSource) ic.lookup("Test/DataSource/Data");
  |         
  |         Connection conn =  null   ;
  |         
  |         Statement stmt = null;
  |         ResultSet rs = null;
  |         try 
  |         {
  |             conn = datasource.getConnection();  
  |    
  |             stmt = conn.createStatement();
  |             rs = stmt.executeQuery(
  |                     "select DISTINCT " +
  |                         "a.ID, " +
  |                         "a.NAME " +
  |                     "from TEST_TABLE a" );
  |             
  |            for( int nbRecords= 1; rs.next(); ++nbRecords ) {
  |                 
  |                 String id = rs.getString( 1 );
  |                 String name = rs.getString( 2 );
  |                 
  |                 System.out.println(String.format("%1$s: %2$s", id, name));
  |                 
  |             }
  |         
  |         DatabaseMetaData metaData = conn.getMetaData();
  |         String catalogTerm = metaData.getCatalogTerm();
  |         System.out.println("CatalogTerm :"+catalogTerm);
  |         //output is as expected    
  |            
  |         ResultSet resultset = metaData.getColumns(conn.getCatalog(), null, "TEST_TABLE", "NAME");// throws an exception  
  | 

The exception :

  |  java.lang.ClassCastException: $Proxy5 cannot be cast to java.sql.ResultSet
  |         at $Proxy4.getColumns(Unknown Source)
  | 


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4175601#4175601

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4175601



More information about the jboss-user mailing list