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" });
}
}Sorry, the "red line" should be:
ResultSet rs = dbmd.getTables(null, "%", "%", new String[] { "TABLE", "VIEW" });