01: package adhoc;
02:
03: import java.sql.Connection;
04: import java.sql.DatabaseMetaData;
05: import java.sql.DriverManager;
06: import java.sql.ResultSet;
07: import java.sql.SQLException;
08: import java.sql.Statement;
09:
10: public class HADBColumnTest {
11:
12: String jdbcUrl = "jdbc:sun:hadb:system@192.168.1.129:15129,192.168.1.129:15109";
13:
14: String user = "system";
15:
16: String pass = "password";
17:
18: Connection con = null;
19:
20: String dropSQL = "drop table bigint_type_table ";
21:
22: String createTableSQL = "CREATE TABLE bigint_type_table "
23: + "( "
24: + " bigint_column integer , pkcol integer PRIMARY KEY not null "
25: + ") ";
26:
27: String insertSQL = "insert into bigint_type_table (bigint_column, pkcol) "
28: + "values (12345, 1) ";
29:
30: public HADBColumnTest() throws Exception {
31: init();
32: }
33:
34: public void init() throws Exception {
35: Class.forName("com.sun.hadb.jdbc.Driver");
36: con = DriverManager.getConnection(jdbcUrl, user, pass);
37: }
38:
39: /**
40: * This fails with a Connection failure - java.io.EOFException
41: * @throws SQLException
42: */
43: public void doTest() throws SQLException {
44: Statement stmt = con.createStatement();
45: try {
46: stmt.execute(dropSQL);
47: } catch (SQLException e) {
48: e.printStackTrace();
49: }
50: stmt.execute(createTableSQL);
51: stmt.executeUpdate(insertSQL);
52: DatabaseMetaData md = con.getMetaData();
53: ResultSet rs = md.getColumns(null, null, "bigint_type_table",
54: "bigint_column");
55: while (rs.next()) {
56: String columnName = rs.getString(4); // COLUMN_NAME
57: System.out.println("columnName: " + columnName);
58: }
59:
60: }
61:
62: public void shutdown() throws SQLException {
63: con.close();
64: }
65:
66: /**
67: * @param args
68: */
69: public static void main(String[] args) throws Exception {
70: // TODO Auto-generated method stub
71: HADBColumnTest test = new HADBColumnTest();
72:
73: test.doTest();
74:
75: test.shutdown();
76: }
77:
78: }
|