01: /*
02: * Copyright (C) CollabraSpace Inc. All rights reserved.
03: */
04: package adhoc;
05:
06: import java.sql.Connection;
07: import java.sql.DatabaseMetaData;
08: import java.sql.DriverManager;
09: import java.sql.ResultSet;
10: import java.sql.SQLException;
11:
12: import net.sourceforge.squirrel_sql.client.ApplicationArguments;
13:
14: public class OracleDatabaseMetaDataTest {
15:
16: String jdbcDriver = "oracle.jdbc.OracleDriver";
17:
18: String jdbcUrl = "jdbc:oracle:thin:@localhost:1521:csuite";
19:
20: String user = "ctrp";
21:
22: String pass = "password";
23:
24: Connection con = null;
25:
26: String catalog = null;
27: String schema = "CTRP";
28: String table = "comments";
29:
30: int[] bestRowConstants = new int[] {
31: DatabaseMetaData.bestRowNotPseudo,
32: DatabaseMetaData.bestRowPseudo,
33: DatabaseMetaData.bestRowSession,
34: DatabaseMetaData.bestRowTemporary,
35: DatabaseMetaData.bestRowTransaction,
36: DatabaseMetaData.bestRowUnknown, };
37:
38: public OracleDatabaseMetaDataTest() throws Exception {
39: init();
40: }
41:
42: public void init() throws Exception {
43: ApplicationArguments.initialize(new String[0]);
44: Class.forName(jdbcDriver);
45: con = DriverManager.getConnection(jdbcUrl, user, pass);
46: }
47:
48: /**
49: * This fails with a Connection failure - java.io.EOFException
50: * @throws SQLException
51: */
52: public void doTest() throws SQLException {
53: //ResultSet rs = con.getMetaData().getTables("dbcopysrc", null, "BIGINT_TYPE_TABLE", new String[]{ "TABLE" });
54: ResultSet rs = con.getMetaData().getTables(catalog, schema,
55: table, new String[] { "TABLE" });
56: while (rs.next()) {
57: System.out.println("Table=" + rs.getString("TABLE_NAME"));
58: }
59: }
60:
61: public void shutdown() throws SQLException {
62: con.close();
63: }
64:
65: /**
66: * @param args
67: */
68: public static void main(String[] args) throws Exception {
69: // TODO Auto-generated method stub
70: OracleDatabaseMetaDataTest test = new OracleDatabaseMetaDataTest();
71:
72: test.doTest();
73:
74: test.shutdown();
75: }
76:
77: }
|