Mercurial > hg > monetdb-java
annotate tests/Test_Wrapper.java @ 261:d4baf8a4b43a
Update Copyright year to 2019
author | Martin van Dinther <martin.van.dinther@monetdbsolutions.com> |
---|---|
date | Thu, 03 Jan 2019 14:43:44 +0100 (2019-01-03) |
parents | c38d4eaf5479 |
children | 54137aeb1f92 |
rev | line source |
---|---|
18
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
1 /* |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
2 * This Source Code Form is subject to the terms of the Mozilla Public |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
5 * |
261
d4baf8a4b43a
Update Copyright year to 2019
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
6 * Copyright 1997 - July 2008 CWI, August 2008 - 2019 MonetDB B.V. |
18
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
7 */ |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
8 |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
9 import java.sql.*; |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
10 |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
11 public class Test_Wrapper { |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
12 public static void main(String[] args) throws Exception { |
27
04fbf3655452
Disable Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); code
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
18
diff
changeset
|
13 // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); // not needed anymore for self registering JDBC drivers |
18
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
14 final Connection con = DriverManager.getConnection(args[0]); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
15 System.out.println("Connected. Auto commit is: " + con.getAutoCommit()); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
16 |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
17 try { |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
18 final String jdbc_pkg = "java.sql."; |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
19 final String monetdb_jdbc_pkg = "nl.cwi.monetdb.jdbc."; |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
20 |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
21 checkIsWrapperFor("Connection", con, jdbc_pkg, "Connection"); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
22 checkIsWrapperFor("Connection", con, monetdb_jdbc_pkg, "MonetConnection"); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
23 checkIsWrapperFor("Connection", con, jdbc_pkg, "Statement"); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
24 checkIsWrapperFor("Connection", con, monetdb_jdbc_pkg, "MonetStatement"); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
25 |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
26 DatabaseMetaData dbmd = con.getMetaData(); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
27 checkIsWrapperFor("DatabaseMetaData", dbmd, jdbc_pkg, "DatabaseMetaData"); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
28 checkIsWrapperFor("DatabaseMetaData", dbmd, monetdb_jdbc_pkg, "MonetDatabaseMetaData"); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
29 checkIsWrapperFor("DatabaseMetaData", dbmd, jdbc_pkg, "Statement"); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
30 checkIsWrapperFor("DatabaseMetaData", dbmd, monetdb_jdbc_pkg, "MonetStatement"); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
31 |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
32 ResultSet rs = dbmd.getSchemas(); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
33 checkIsWrapperFor("ResultSet", rs, jdbc_pkg, "ResultSet"); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
34 checkIsWrapperFor("ResultSet", rs, monetdb_jdbc_pkg, "MonetResultSet"); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
35 checkIsWrapperFor("ResultSet", rs, jdbc_pkg, "Statement"); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
36 checkIsWrapperFor("ResultSet", rs, monetdb_jdbc_pkg, "MonetStatement"); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
37 |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
38 ResultSetMetaData rsmd = rs.getMetaData(); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
39 checkIsWrapperFor("ResultSetMetaData", rsmd, jdbc_pkg, "ResultSetMetaData"); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
40 checkIsWrapperFor("ResultSetMetaData", rsmd, monetdb_jdbc_pkg, "MonetResultSet"); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
41 checkIsWrapperFor("ResultSetMetaData", rsmd, monetdb_jdbc_pkg, "MonetResultSet$rsmdw"); // it is a private class of MonetResultSet |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
42 checkIsWrapperFor("ResultSetMetaData", rsmd, jdbc_pkg, "Statement"); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
43 checkIsWrapperFor("ResultSetMetaData", rsmd, monetdb_jdbc_pkg, "MonetStatement"); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
44 |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
45 rs.close(); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
46 |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
47 Statement stmt = con.createStatement(); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
48 checkIsWrapperFor("Statement", stmt, jdbc_pkg, "Statement"); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
49 checkIsWrapperFor("Statement", stmt, monetdb_jdbc_pkg, "MonetStatement"); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
50 checkIsWrapperFor("Statement", stmt, jdbc_pkg, "Connection"); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
51 checkIsWrapperFor("Statement", stmt, monetdb_jdbc_pkg, "MonetConnection"); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
52 |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
53 stmt.close(); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
54 |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
55 PreparedStatement pstmt = con.prepareStatement("SELECT name FROM sys.tables WHERE system AND name like ?"); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
56 checkIsWrapperFor("PreparedStatement", pstmt, jdbc_pkg, "PreparedStatement"); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
57 checkIsWrapperFor("PreparedStatement", pstmt, monetdb_jdbc_pkg, "MonetPreparedStatement"); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
58 checkIsWrapperFor("PreparedStatement", pstmt, jdbc_pkg, "Statement"); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
59 checkIsWrapperFor("PreparedStatement", pstmt, monetdb_jdbc_pkg, "MonetStatement"); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
60 checkIsWrapperFor("PreparedStatement", pstmt, jdbc_pkg, "Connection"); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
61 checkIsWrapperFor("PreparedStatement", pstmt, monetdb_jdbc_pkg, "MonetConnection"); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
62 |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
63 ParameterMetaData pmd = pstmt.getParameterMetaData(); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
64 checkIsWrapperFor("ParameterMetaData", pmd, jdbc_pkg, "ParameterMetaData"); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
65 checkIsWrapperFor("ParameterMetaData", pmd, monetdb_jdbc_pkg, "MonetPreparedStatement"); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
66 checkIsWrapperFor("ParameterMetaData", pmd, monetdb_jdbc_pkg, "MonetPreparedStatement$pmdw"); // it is a private class of MonetPreparedStatement |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
67 checkIsWrapperFor("ParameterMetaData", pmd, jdbc_pkg, "Connection"); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
68 checkIsWrapperFor("ParameterMetaData", pmd, monetdb_jdbc_pkg, "MonetConnection"); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
69 |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
70 ResultSetMetaData psrsmd = pstmt.getMetaData(); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
71 checkIsWrapperFor("PrepStmt ResultSetMetaData", psrsmd, jdbc_pkg, "ResultSetMetaData"); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
72 checkIsWrapperFor("PrepStmt ResultSetMetaData", psrsmd, monetdb_jdbc_pkg, "MonetPreparedStatement"); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
73 checkIsWrapperFor("PrepStmt ResultSetMetaData", psrsmd, monetdb_jdbc_pkg, "MonetPreparedStatement$rsmdw"); // it is a private class of MonetPreparedStatement |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
74 checkIsWrapperFor("PrepStmt ResultSetMetaData", psrsmd, jdbc_pkg, "Connection"); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
75 checkIsWrapperFor("PrepStmt ResultSetMetaData", psrsmd, monetdb_jdbc_pkg, "MonetConnection"); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
76 |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
77 pstmt.close(); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
78 |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
79 } catch (SQLException e) { |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
80 while ((e = e.getNextException()) != null) |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
81 System.out.println("FAILED :( " + e.getMessage()); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
82 } |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
83 con.close(); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
84 } |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
85 |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
86 private static void checkIsWrapperFor(String objnm, Wrapper obj, String pkgnm, String classnm) { |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
87 try { |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
88 Class<?> clazz = Class.forName(pkgnm + classnm); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
89 boolean isWrapper = obj.isWrapperFor(clazz); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
90 System.out.print(objnm + ". isWrapperFor(" + classnm + ") returns: " + isWrapper); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
91 if (isWrapper) { |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
92 Object wobj = obj.unwrap(clazz); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
93 System.out.print("\tCalled unwrap(). Returned object is " + (wobj != null ? "not null, so oke" : "null !!")); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
94 } |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
95 System.out.println(); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
96 } catch (ClassNotFoundException cnfe) { |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
97 System.out.println(cnfe.toString()); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
98 } catch (SQLException se) { |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
99 System.out.println(se.getMessage()); |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
100 } |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
101 } |
8e57d20b5e80
Corrected implementation of java.sql.Wrapper methods isWrapperFor() and unwrap().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
diff
changeset
|
102 } |