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 MySQLDatabaseMetaDataTest {
15:
16: String jdbcDriver = "com.mysql.jdbc.Driver";
17:
18: String jdbcUrl = "jdbc:mysql://localhost:3306/test";
19:
20: String user = "test.user";
21:
22: String pass = "password";
23:
24: Connection con = null;
25:
26: String schema = "dbcopysrc";
27: String table = "BIGINT_TYPE_TABLE";
28:
29: int[] bestRowConstants = new int[] {
30: DatabaseMetaData.bestRowNotPseudo,
31: DatabaseMetaData.bestRowPseudo,
32: DatabaseMetaData.bestRowSession,
33: DatabaseMetaData.bestRowTemporary,
34: DatabaseMetaData.bestRowTransaction,
35: DatabaseMetaData.bestRowUnknown, };
36:
37: public MySQLDatabaseMetaDataTest() throws Exception {
38: init();
39: }
40:
41: public void init() throws Exception {
42: ApplicationArguments.initialize(new String[0]);
43: Class.forName(jdbcDriver);
44: con = DriverManager.getConnection(jdbcUrl, user, pass);
45: }
46:
47: /**
48: * This fails with a Connection failure - java.io.EOFException
49: * @throws SQLException
50: */
51: public void doTest() throws SQLException {
52: //ResultSet rs = con.getMetaData().getTables("dbcopysrc", null, "BIGINT_TYPE_TABLE", new String[]{ "TABLE" });
53: ResultSet rs = con.getMetaData().getTables(null, null, "%",
54: new String[] { "TABLE" });
55: while (rs.next()) {
56: System.out.println("Table=" + rs.getString("TABLE_NAME"));
57: }
58: }
59:
60: public void shutdown() throws SQLException {
61: con.close();
62: }
63:
64: /**
65: * @param args
66: */
67: public static void main(String[] args) throws Exception {
68: // TODO Auto-generated method stub
69: MySQLDatabaseMetaDataTest test = new MySQLDatabaseMetaDataTest();
70:
71: test.doTest();
72:
73: test.shutdown();
74: }
75:
76: }
|