1 Reply Latest reply on Aug 27, 2009 12:09 AM by poweryoung

    Fail to get tables by a remote Datasource deployed in JBOSS

      Hi, all:

      I try to use DatabaseMetaData to get all tables and views from a Oracle database. But exception is thrown at the red line. You can see that I look up a remote DataSource and get connection from the data source. But if I use DriverManager.getConnection(url, user, pwd) way to get connection. This issue does not exist. I can get all the tables and views successfully...

      Any help from you will be much appreciated!

      public class Test {
      
       public static void main(String[] args) throws Exception {
      
       Properties props = new Properties();
      
       props.put(Context.PROVIDER_URL, "jnp://10.111.3.161:1099");
      
       props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      
       Context ctx = new InitialContext(props);
      
       DataSource ds = (DataSource)ctx.lookup("OracleDS");
      
       Connection conn = ds.getConnection();
      
       DatabaseMetaData dbmd = conn.getMetaData();
      
       ResultSet rs = dbmd.getTables(null, "%", "%", new String[] { "TABLE", "VIEW" });
      
       }
      
      }


      Exception:

      Exception in thread "main" java.lang.ClassCastException: $Proxy3

      at $Proxy2.getTables(Unknown Source)

      at Test.main(Test.java:62)