comparison tests/Test_Dobjects.java @ 0:a5a898f6886c

Copy of MonetDB java directory changeset e6e32756ad31.
author Sjoerd Mullender <sjoerd@acm.org>
date Wed, 21 Sep 2016 09:34:48 +0200 (2016-09-21)
parents
children 04fbf3655452
comparison
equal deleted inserted replaced
-1:000000000000 0:a5a898f6886c
1 /*
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 *
6 * Copyright 1997 - July 2008 CWI, August 2008 - 2016 MonetDB B.V.
7 */
8
9 import java.sql.*;
10 import java.util.*;
11
12 public class Test_Dobjects {
13 private static void dumpResultSet(ResultSet rs) throws SQLException {
14 ResultSetMetaData rsmd = rs.getMetaData();
15 System.out.println("Resultset with " + rsmd.getColumnCount() + " columns");
16 for (int col = 1; col <= rsmd.getColumnCount(); col++) {
17 System.out.print(rsmd.getColumnName(col) + "\t");
18 }
19 System.out.println();
20 while (rs.next()) {
21 for (int col = 1; col <= rsmd.getColumnCount(); col++) {
22 System.out.print(rs.getString(col) + "\t");
23 }
24 System.out.println();
25 }
26 }
27
28 public static void main(String[] args) throws Exception {
29 Class.forName("nl.cwi.monetdb.jdbc.MonetDriver");
30 Connection con = DriverManager.getConnection(args[0]);
31 Statement stmt = con.createStatement();
32 PreparedStatement pstmt;
33 DatabaseMetaData dbmd = con.getMetaData();
34
35 try {
36 // inspect the catalog by use of dbmd functions
37 dumpResultSet(dbmd.getCatalogs());
38 // dumpResultSet(dbmd.getSchemas()); // this produces different outputs on different platforms due to dependency on SAMTOOLS and NETCDF. so exclude it
39 dumpResultSet(dbmd.getSchemas(null, "sys"));
40 dumpResultSet(dbmd.getTables(null, "sys", null, null));
41 dumpResultSet(dbmd.getUDTs(null, "sys", null, null));
42 int[] UDTtypes = { Types.STRUCT, Types.DISTINCT };
43 dumpResultSet(dbmd.getUDTs(null, "sys", null, UDTtypes));
44 } catch (SQLException e) {
45 System.out.println("FAILED :( "+ e.getMessage());
46 System.out.println("ABORTING TEST!!!");
47 }
48
49 con.close();
50 }
51 }