Changeset: a4c05f611cd8 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a4c05f611cd8
Modified Files:
        java/tests/Makefile.ag
        java/tests/Test_Dobjects.java
        java/tests/build.xml
Branch: Dec2011
Log Message:

JDBC: add (too short) DatabaseMetaData test


diffs (98 lines):

diff --git a/java/tests/Makefile.ag b/java/tests/Makefile.ag
--- a/java/tests/Makefile.ag
+++ b/java/tests/Makefile.ag
@@ -22,6 +22,7 @@ EXTRA_DIST = \
                Test_Creplysize.java \
                Test_Csavepoints.java \
                Test_Ctransaction.java \
+               Test_Dobjects.java \
                Test_PSgeneratedkeys.java \
                Test_PSlargeresponse.java \
                Test_PSlargeamount.java \
diff --git a/java/tests/Test_Dobjects.java b/java/tests/Test_Dobjects.java
new file mode 100644
--- /dev/null
+++ b/java/tests/Test_Dobjects.java
@@ -0,0 +1,58 @@
+/*
+ * The contents of this file are subject to the MonetDB Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.monetdb.org/Legal/MonetDBLicense
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is the MonetDB Database System.
+ *
+ * The Initial Developer of the Original Code is CWI.
+ * Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
+ * Copyright August 2008-2011 MonetDB B.V.
+ * All Rights Reserved.
+ */
+
+import java.sql.*;
+import java.util.*;
+
+public class Test_Dobjects {
+       private static void dumpResultSet(ResultSet rs) throws SQLException {
+               ResultSetMetaData rsmd = rs.getMetaData();
+               System.out.println("Resultset with " + rsmd.getColumnCount() + 
" columns");
+               for (int col = 1; col <= rsmd.getColumnCount(); col++) {
+                       System.out.print(rsmd.getColumnName(col) + "\t");
+               }
+               System.out.println();
+               while (rs.next()) {
+                       for (int col = 1; col <= rsmd.getColumnCount(); col++) {
+                               System.out.print(rs.getString(col) + "\t");
+                       }
+                       System.out.println();
+               }
+       }
+
+       public static void main(String[] args) throws Exception {
+               Class.forName("nl.cwi.monetdb.jdbc.MonetDriver");
+               Connection con = DriverManager.getConnection(args[0]);
+               Statement stmt = con.createStatement();
+               PreparedStatement pstmt;
+               DatabaseMetaData dbmd = con.getMetaData();
+
+               try {
+                       // inspect the catalog by use of dbmd functions
+                       dumpResultSet(dbmd.getCatalogs());
+                       dumpResultSet(dbmd.getSchemas());
+                       dumpResultSet(dbmd.getTables(null, null, null, null));
+               } catch (SQLException e) {
+                       System.out.println("FAILED :( "+ e.getMessage());
+                       System.out.println("ABORTING TEST!!!");
+               }
+
+               con.close();
+       }
+}
diff --git a/java/tests/build.xml b/java/tests/build.xml
--- a/java/tests/build.xml
+++ b/java/tests/build.xml
@@ -110,6 +110,7 @@ All Rights Reserved.
     <antcall target="Test_Creplysize" />
     <antcall target="Test_Csavepoints" />
     <antcall target="Test_Ctransaction" />
+    <antcall target="Test_Dobjects" />
     <antcall target="Test_PSgeneratedkeys" />
     <antcall target="Test_PSlargeresponse" />
     <antcall target="Test_PSlargeamount" />
@@ -183,6 +184,12 @@ All Rights Reserved.
     </antcall>
   </target>
 
+  <target name="Test_Dobjects">
+    <antcall target="test_class">
+      <param name="test.class" value="Test_Dobjects" />
+    </antcall>
+  </target>
+
   <target name="Test_Sbatching">
     <antcall target="test_class">
       <param name="test.class" value="Test_Sbatching" />
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to