Mercurial > hg > monetdb-java
annotate src/main/java/org/monetdb/jdbc/MonetDriver.java @ 869:676725ad17b5
Remove not needed/used internal method checkValidProperty()
Make the MonetConnection target variable private and final.
author | Martin van Dinther <martin.van.dinther@monetdbsolutions.com> |
---|---|
date | Thu, 01 Feb 2024 20:55:01 +0100 (14 months ago) |
parents | d9a45743536d |
children | ff7dbded88c8 |
rev | line source |
---|---|
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1 /* |
833
e890195256ac
Update copyright for the new year, move to MonetDB Foundation, add SPDX.
Sjoerd Mullender <sjoerd@acm.org>
parents:
825
diff
changeset
|
2 * SPDX-License-Identifier: MPL-2.0 |
e890195256ac
Update copyright for the new year, move to MonetDB Foundation, add SPDX.
Sjoerd Mullender <sjoerd@acm.org>
parents:
825
diff
changeset
|
3 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
4 * This Source Code Form is subject to the terms of the Mozilla Public |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
5 * License, v. 2.0. If a copy of the MPL was not distributed with this |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
7 * |
833
e890195256ac
Update copyright for the new year, move to MonetDB Foundation, add SPDX.
Sjoerd Mullender <sjoerd@acm.org>
parents:
825
diff
changeset
|
8 * Copyright 2024 MonetDB Foundation; |
e890195256ac
Update copyright for the new year, move to MonetDB Foundation, add SPDX.
Sjoerd Mullender <sjoerd@acm.org>
parents:
825
diff
changeset
|
9 * Copyright August 2008 - 2023 MonetDB B.V.; |
e890195256ac
Update copyright for the new year, move to MonetDB Foundation, add SPDX.
Sjoerd Mullender <sjoerd@acm.org>
parents:
825
diff
changeset
|
10 * Copyright 1997 - July 2008 CWI. |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
11 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
12 |
391
f523727db392
Moved Java classes from packages starting with nl.cwi.monetdb.* to package org.monetdb.*
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
381
diff
changeset
|
13 package org.monetdb.jdbc; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
14 |
793
5bfe3357fb1c
Use the new url parser
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
788
diff
changeset
|
15 import org.monetdb.mcl.net.Target; |
5bfe3357fb1c
Use the new url parser
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
788
diff
changeset
|
16 import org.monetdb.mcl.net.ValidationError; |
5bfe3357fb1c
Use the new url parser
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
788
diff
changeset
|
17 |
5bfe3357fb1c
Use the new url parser
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
788
diff
changeset
|
18 import java.net.URISyntaxException; |
869
676725ad17b5
Remove not needed/used internal method checkValidProperty()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
852
diff
changeset
|
19 import java.sql.Connection; |
676725ad17b5
Remove not needed/used internal method checkValidProperty()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
852
diff
changeset
|
20 import java.sql.Driver; |
676725ad17b5
Remove not needed/used internal method checkValidProperty()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
852
diff
changeset
|
21 import java.sql.DriverManager; |
676725ad17b5
Remove not needed/used internal method checkValidProperty()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
852
diff
changeset
|
22 import java.sql.DriverPropertyInfo; |
676725ad17b5
Remove not needed/used internal method checkValidProperty()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
852
diff
changeset
|
23 import java.sql.SQLException; |
676725ad17b5
Remove not needed/used internal method checkValidProperty()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
852
diff
changeset
|
24 import java.sql.SQLFeatureNotSupportedException; |
676725ad17b5
Remove not needed/used internal method checkValidProperty()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
852
diff
changeset
|
25 import java.sql.Types; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
26 import java.util.Map.Entry; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
27 import java.util.Properties; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
28 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
29 /** |
451
3dfcd06fd8ba
Correcting typos in documentation text. Also improved the readability of the generated javadoc documents.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
415
diff
changeset
|
30 *<pre> |
3dfcd06fd8ba
Correcting typos in documentation text. Also improved the readability of the generated javadoc documents.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
415
diff
changeset
|
31 * A JDBC {@link Driver} suitable for the MonetDB RDBMS. |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
32 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
33 * This driver will be used by the DriverManager to determine if an URL |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
34 * is to be handled by this driver, and if it does, then this driver |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
35 * will supply a Connection suitable for MonetDB. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
36 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
37 * This class has no explicit constructor, the default constructor |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
38 * generated by the Java compiler will be sufficient since nothing has |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
39 * to be set in order to use this driver. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
40 * |
333
55330e40cbf1
Eliminate the need for private static final variables which are filled by preproccesor.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
295
diff
changeset
|
41 * This Driver supports MonetDB database URLs. MonetDB URLs are defined as: |
626
06d69b82d409
Resolve javadoc error and warnings :
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
610
diff
changeset
|
42 * <code>jdbc:monetdb://<host>[:<port>]/<database></code> |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
43 * where [:<port>] denotes that a port is optional. If not |
785
e00866975421
Get rid of JDBC_DEF_PORT
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
784
diff
changeset
|
44 * given, port 50000 will be used. |
451
3dfcd06fd8ba
Correcting typos in documentation text. Also improved the readability of the generated javadoc documents.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
415
diff
changeset
|
45 *</pre> |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
46 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
47 * @author Fabian Groffen |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
48 */ |
768
a80c21fe7bb2
Removed deprecated nl.cwi.monetdb.*.* classes and package.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
761
diff
changeset
|
49 public final class MonetDriver implements Driver { |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
50 // the url kind will be jdbc:monetdb://<host>[:<port>]/<database> |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
51 // Chapter 9.2.1 from Sun JDBC 3.0 specification |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
52 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
53 // initialize this class: register it at the DriverManager |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
54 // Chapter 9.2 from Sun JDBC 3.0 specification |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
55 static { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
56 try { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
57 DriverManager.registerDriver(new MonetDriver()); |
8
a27ee2cb14a0
Replace String methods equals("") and "".equals( with isEmpty()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
0
diff
changeset
|
58 } catch (SQLException e) { |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
59 e.printStackTrace(); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
60 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
61 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
62 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
63 //== methods of interface Driver |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
64 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
65 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
66 * Retrieves whether the driver thinks that it can open a connection to the |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
67 * given URL. Typically drivers will return true if they understand the |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
68 * subprotocol specified in the URL and false if they do not. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
69 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
70 * @param url the URL of the database |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
71 * @return true if this driver understands the given URL; false otherwise |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
72 */ |
144
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
73 @Override |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
262
diff
changeset
|
74 public boolean acceptsURL(final String url) { |
834
5aa19bbed0d6
Comments and formatting
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
809
diff
changeset
|
75 if (url == null) |
795
04a27386789f
MonetDriver: Use only the properties if URL is exactly "jdbc:monetdb:"
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
793
diff
changeset
|
76 return false; |
834
5aa19bbed0d6
Comments and formatting
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
809
diff
changeset
|
77 return url.startsWith("jdbc:monetdb:") || url.startsWith("jdbc:monetdbs:"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
78 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
79 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
80 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
81 * Attempts to make a database connection to the given URL. The driver |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
82 * should return "null" if it realizes it is the wrong kind of driver to |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
83 * connect to the given URL. This will be common, as when the JDBC driver |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
84 * manager is asked to connect to a given URL it passes the URL to each |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
85 * loaded driver in turn. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
86 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
87 * The driver should throw an SQLException if it is the right driver to |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
88 * connect to the given URL but has trouble connecting to the database. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
89 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
90 * The java.util.Properties argument can be used to pass arbitrary string |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
91 * tag/value pairs as connection arguments. Normally at least "user" and |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
92 * "password" properties should be included in the Properties object. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
93 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
94 * @param url the URL of the database to which to connect |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
95 * @param info a list of arbitrary string tag/value pairs as connection |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
96 * arguments. Normally at least a "user" and "password" property |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
97 * should be included |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
98 * @return a Connection object that represents a connection to the URL |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
99 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
100 */ |
144
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
101 @Override |
869
676725ad17b5
Remove not needed/used internal method checkValidProperty()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
852
diff
changeset
|
102 public Connection connect(final String url, final Properties info) throws SQLException { |
199
e87d89d371f1
Make some public non-JDBC methods accessable only to classes of the same package.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
194
diff
changeset
|
103 // url should be of style jdbc:monetdb://<host>/<database> |
e87d89d371f1
Make some public non-JDBC methods accessable only to classes of the same package.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
194
diff
changeset
|
104 if (!acceptsURL(url)) |
254
27b7166860c8
According to the JDBC specification if the JDBC URL is invalid, return null instead of an exception, so the DriverManager can keep looking for a suitable JDBC driver.
Pedro Ferreira <pedro.ferreira@monetdbsolutions.com>
parents:
224
diff
changeset
|
105 return null; |
199
e87d89d371f1
Make some public non-JDBC methods accessable only to classes of the same package.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
194
diff
changeset
|
106 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
107 try { |
809
aa4108a5bc34
Move more URL and properties parsing responsibilities to Target
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
795
diff
changeset
|
108 Target target = new Target(url, info); |
aa4108a5bc34
Move more URL and properties parsing responsibilities to Target
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
795
diff
changeset
|
109 return new MonetConnection(target); |
793
5bfe3357fb1c
Use the new url parser
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
788
diff
changeset
|
110 } catch (ValidationError | URISyntaxException e) { |
5bfe3357fb1c
Use the new url parser
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
788
diff
changeset
|
111 throw new SQLException(e.getMessage()); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
112 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
113 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
114 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
115 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
116 * Retrieves the driver's major version number. Initially this should be 1. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
117 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
118 * @return this driver's major version number |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
119 */ |
144
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
120 @Override |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
121 public int getMajorVersion() { |
825
23f84ff380c2
Now we have a MonetVersion class use it from MonetDatabaseMetaData also.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
820
diff
changeset
|
122 return MonetVersion.majorVersion; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
123 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
124 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
125 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
126 * Gets the driver's minor version number. Initially this should be 0. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
127 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
128 * @return this driver's minor version number |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
129 */ |
144
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
130 @Override |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
131 public int getMinorVersion() { |
825
23f84ff380c2
Now we have a MonetVersion class use it from MonetDatabaseMetaData also.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
820
diff
changeset
|
132 return MonetVersion.minorVersion; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
133 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
134 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
135 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
136 * Gets information about the possible properties for this driver. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
137 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
138 * The getPropertyInfo method is intended to allow a generic GUI tool to |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
139 * discover what properties it should prompt a human for in order to get |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
140 * enough information to connect to a database. Note that depending on the |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
141 * values the human has supplied so far, additional values may become |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
142 * necessary, so it may be necessary to iterate though several calls to the |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
143 * getPropertyInfo method. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
144 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
145 * @param url the URL of the database to which to connect |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
146 * @param info a proposed list of tag/value pairs that will be sent on |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
147 * connect open |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
148 * @return an array of DriverPropertyInfo objects describing possible |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
149 * properties. This array may be an empty array if no properties |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
150 * are required. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
151 */ |
144
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
152 @Override |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
262
diff
changeset
|
153 public DriverPropertyInfo[] getPropertyInfo(final String url, final Properties info) { |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
154 if (!acceptsURL(url)) |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
155 return null; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
156 |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
262
diff
changeset
|
157 final String[] boolean_choices = new String[] { "true", "false" }; |
658
108123ca6889
Add autocommit=true/false option to jdbc url
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
642
diff
changeset
|
158 final DriverPropertyInfo[] dpi = new DriverPropertyInfo[10]; // we currently support 10 connection properties |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
159 |
224
ea729e0cf24d
Improve and extend MonetDriver.getPropertyInfo() with choice values
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
223
diff
changeset
|
160 DriverPropertyInfo prop = new DriverPropertyInfo("user", info != null ? info.getProperty("user") : null); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
161 prop.required = true; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
162 prop.description = "The user loginname to use when authenticating on the database server"; |
224
ea729e0cf24d
Improve and extend MonetDriver.getPropertyInfo() with choice values
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
223
diff
changeset
|
163 dpi[0] = prop; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
164 |
224
ea729e0cf24d
Improve and extend MonetDriver.getPropertyInfo() with choice values
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
223
diff
changeset
|
165 prop = new DriverPropertyInfo("password", info != null ? info.getProperty("password") : null); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
166 prop.required = true; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
167 prop.description = "The password to use when authenticating on the database server"; |
224
ea729e0cf24d
Improve and extend MonetDriver.getPropertyInfo() with choice values
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
223
diff
changeset
|
168 dpi[1] = prop; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
169 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
170 prop = new DriverPropertyInfo("debug", "false"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
171 prop.required = false; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
172 prop.description = "Whether or not to create a log file for debugging purposes"; |
224
ea729e0cf24d
Improve and extend MonetDriver.getPropertyInfo() with choice values
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
223
diff
changeset
|
173 prop.choices = boolean_choices; |
ea729e0cf24d
Improve and extend MonetDriver.getPropertyInfo() with choice values
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
223
diff
changeset
|
174 dpi[2] = prop; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
175 |
224
ea729e0cf24d
Improve and extend MonetDriver.getPropertyInfo() with choice values
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
223
diff
changeset
|
176 prop = new DriverPropertyInfo("logfile", null); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
177 prop.required = false; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
178 prop.description = "The filename to write the debug log to. Only takes effect if debug is set to true. If the file exists, an incrementing number is added, till the filename is unique."; |
224
ea729e0cf24d
Improve and extend MonetDriver.getPropertyInfo() with choice values
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
223
diff
changeset
|
179 dpi[3] = prop; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
180 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
181 prop = new DriverPropertyInfo("language", "sql"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
182 prop.required = false; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
183 prop.description = "What language to use for MonetDB conversations (experts only)"; |
333
55330e40cbf1
Eliminate the need for private static final variables which are filled by preproccesor.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
295
diff
changeset
|
184 prop.choices = new String[] { "sql", "mal" }; |
224
ea729e0cf24d
Improve and extend MonetDriver.getPropertyInfo() with choice values
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
223
diff
changeset
|
185 dpi[4] = prop; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
186 |
224
ea729e0cf24d
Improve and extend MonetDriver.getPropertyInfo() with choice values
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
223
diff
changeset
|
187 prop = new DriverPropertyInfo("hash", null); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
188 prop.required = false; |
363
34ce6e1b1be8
Remove support for deprecated MD5 encryption algorithm in MapiSocket.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
350
diff
changeset
|
189 prop.description = "Force the use of the given hash algorithm (SHA512 or SHA384 or SHA256 or SHA1) during challenge response"; |
34ce6e1b1be8
Remove support for deprecated MD5 encryption algorithm in MapiSocket.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
350
diff
changeset
|
190 prop.choices = new String[] { "SHA512", "SHA384", "SHA256", "SHA1" }; |
224
ea729e0cf24d
Improve and extend MonetDriver.getPropertyInfo() with choice values
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
223
diff
changeset
|
191 dpi[5] = prop; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
192 |
381
11c30e3b7966
Set the connection properties treat_clob_as_varchar and treat_blob_as_binary to true by default for faster processing (less objects created, less memory needed) when querying CLOB or BLOB column data.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
380
diff
changeset
|
193 prop = new DriverPropertyInfo("treat_blob_as_binary", "true"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
194 prop.required = false; |
381
11c30e3b7966
Set the connection properties treat_clob_as_varchar and treat_blob_as_binary to true by default for faster processing (less objects created, less memory needed) when querying CLOB or BLOB column data.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
380
diff
changeset
|
195 prop.description = "Should blob columns be mapped to Types.VARBINARY instead of Types.BLOB in ResultSets and PreparedStatements"; // recommend for increased performance due to less overhead |
224
ea729e0cf24d
Improve and extend MonetDriver.getPropertyInfo() with choice values
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
223
diff
changeset
|
196 prop.choices = boolean_choices; |
ea729e0cf24d
Improve and extend MonetDriver.getPropertyInfo() with choice values
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
223
diff
changeset
|
197 dpi[6] = prop; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
198 |
381
11c30e3b7966
Set the connection properties treat_clob_as_varchar and treat_blob_as_binary to true by default for faster processing (less objects created, less memory needed) when querying CLOB or BLOB column data.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
380
diff
changeset
|
199 prop = new DriverPropertyInfo("treat_clob_as_varchar", "true"); |
175
8700d9ef2ace
Added possibility via a connection property to let the JDBC driver
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
200 prop.required = false; |
381
11c30e3b7966
Set the connection properties treat_clob_as_varchar and treat_blob_as_binary to true by default for faster processing (less objects created, less memory needed) when querying CLOB or BLOB column data.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
380
diff
changeset
|
201 prop.description = "Should clob columns be mapped to Types.VARCHAR instead of Types.CLOB in ResultSets and PreparedStatements"; // recommend for increased performance due to less overhead |
224
ea729e0cf24d
Improve and extend MonetDriver.getPropertyInfo() with choice values
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
223
diff
changeset
|
202 prop.choices = boolean_choices; |
ea729e0cf24d
Improve and extend MonetDriver.getPropertyInfo() with choice values
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
223
diff
changeset
|
203 dpi[7] = prop; |
175
8700d9ef2ace
Added possibility via a connection property to let the JDBC driver
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
204 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
205 prop = new DriverPropertyInfo("so_timeout", "0"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
206 prop.required = false; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
207 prop.description = "Defines the maximum time to wait in milliseconds on a blocking read socket call"; // this corresponds to the Connection.setNetworkTimeout() method introduced in JDBC 4.1 |
224
ea729e0cf24d
Improve and extend MonetDriver.getPropertyInfo() with choice values
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
223
diff
changeset
|
208 dpi[8] = prop; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
209 |
658
108123ca6889
Add autocommit=true/false option to jdbc url
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
642
diff
changeset
|
210 prop = new DriverPropertyInfo("autocommit", "true"); |
224
ea729e0cf24d
Improve and extend MonetDriver.getPropertyInfo() with choice values
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
223
diff
changeset
|
211 prop.required = false; |
658
108123ca6889
Add autocommit=true/false option to jdbc url
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
642
diff
changeset
|
212 prop.description = "Whether the connection should start in auto-commit mode"; |
224
ea729e0cf24d
Improve and extend MonetDriver.getPropertyInfo() with choice values
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
223
diff
changeset
|
213 prop.choices = boolean_choices; |
ea729e0cf24d
Improve and extend MonetDriver.getPropertyInfo() with choice values
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
223
diff
changeset
|
214 dpi[9] = prop; |
ea729e0cf24d
Improve and extend MonetDriver.getPropertyInfo() with choice values
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
223
diff
changeset
|
215 |
ea729e0cf24d
Improve and extend MonetDriver.getPropertyInfo() with choice values
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
223
diff
changeset
|
216 return dpi; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
217 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
218 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
219 /** |
194
1296dbcc4958
Resolved javadoc many errors and warnings, such as:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
180
diff
changeset
|
220 * Reports whether this driver is a genuine JDBC Compliant™ driver. A |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
221 * driver may only report true here if it passes the JDBC compliance tests; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
222 * otherwise it is required to return false. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
223 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
224 * JDBC compliance requires full support for the JDBC API and full support |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
225 * for SQL 92 Entry Level. It is expected that JDBC compliant drivers will |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
226 * be available for all the major commercial databases. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
227 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
228 * This method is not intended to encourage the development of non-JDBC |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
229 * compliant drivers, but is a recognition of the fact that some vendors are |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
230 * interested in using the JDBC API and framework for lightweight databases |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
231 * that do not support full database functionality, or for special databases |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
232 * such as document information retrieval where a SQL implementation may not |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
233 * be feasible. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
234 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
235 * @return true if this driver is JDBC Compliant; false otherwise |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
236 */ |
144
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
237 @Override |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
238 public boolean jdbcCompliant() { |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
262
diff
changeset
|
239 // We're not fully JDBC compliant, but what we support is compliant |
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
262
diff
changeset
|
240 return false; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
241 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
242 |
144
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
243 /** |
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
244 * Return the parent Logger of all the Loggers used by this data source. |
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
245 * This should be the Logger farthest from the root Logger that is |
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
246 * still an ancestor of all of the Loggers used by this data source. |
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
247 * Configuring this Logger will affect all of the log messages |
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
248 * generated by the data source. |
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
249 * In the worst case, this may be the root Logger. |
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
250 * |
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
251 * @return the parent Logger for this data source |
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
252 * @throws SQLFeatureNotSupportedException if the data source does |
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
253 * not use java.util.logging |
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
254 * @since 1.7 |
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
255 */ |
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
256 @Override |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
262
diff
changeset
|
257 public java.util.logging.Logger getParentLogger() throws SQLFeatureNotSupportedException { |
262
2d62ca1f758b
Moved utility method newSQLFeatureNotSupportedException(String name) from MonetPreparedStatement.java and MonetResultSet.java
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
261
diff
changeset
|
258 throw MonetWrapper.newSQLFeatureNotSupportedException("getParentLogger"); |
144
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
259 } |
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
260 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
261 //== end methods of interface driver |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
262 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
263 |
333
55330e40cbf1
Eliminate the need for private static final variables which are filled by preproccesor.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
295
diff
changeset
|
264 /** |
55330e40cbf1
Eliminate the need for private static final variables which are filled by preproccesor.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
295
diff
changeset
|
265 * Returns a touched up identifying version string of this driver. |
391
f523727db392
Moved Java classes from packages starting with nl.cwi.monetdb.* to package org.monetdb.*
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
381
diff
changeset
|
266 * It is made public as it is called from org/monetdb/client/JdbcClient.java |
333
55330e40cbf1
Eliminate the need for private static final variables which are filled by preproccesor.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
295
diff
changeset
|
267 * @return the version string |
55330e40cbf1
Eliminate the need for private static final variables which are filled by preproccesor.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
295
diff
changeset
|
268 */ |
55330e40cbf1
Eliminate the need for private static final variables which are filled by preproccesor.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
295
diff
changeset
|
269 public static final String getDriverVersion() { |
786
f7df78989ac5
Generate MonetVersion.java rather than MonetDriver.java
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
785
diff
changeset
|
270 return MonetVersion.driverVersion; |
333
55330e40cbf1
Eliminate the need for private static final variables which are filled by preproccesor.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
295
diff
changeset
|
271 } |
55330e40cbf1
Eliminate the need for private static final variables which are filled by preproccesor.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
295
diff
changeset
|
272 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
273 /** A static Map containing the mapping between MonetDB types and Java SQL types */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
274 /* use SELECT sqlname, * FROM sys.types order by 1, id; to view all MonetDB types */ |
380
bf521f343172
Added support for new Java 8 java.sql.Types: Types.TIME_WITH_TIMEZONE and Types.TIMESTAMP_WITH_TIMEZONE.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
379
diff
changeset
|
275 /* see http://docs.oracle.com/javase/8/docs/api/java/sql/Types.html to view all supported java SQL types */ |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
262
diff
changeset
|
276 private static final java.util.Map<String, Integer> typeMap = new java.util.HashMap<String, Integer>(); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
277 static { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
278 // fill the typeMap once |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
279 // typeMap.put("any", Integer.valueOf(Types.???)); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
280 typeMap.put("bigint", Integer.valueOf(Types.BIGINT)); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
281 typeMap.put("blob", Integer.valueOf(Types.BLOB)); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
282 typeMap.put("boolean", Integer.valueOf(Types.BOOLEAN)); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
283 typeMap.put("char", Integer.valueOf(Types.CHAR)); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
284 typeMap.put("clob", Integer.valueOf(Types.CLOB)); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
285 typeMap.put("date", Integer.valueOf(Types.DATE)); |
415
50e43af49d47
Improved DatabaseMetaData.getTypeInfo() output for temporal data types: sec_interval, day_interval, month_interval, date, time, timetz, timestamp and timestamptz.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
414
diff
changeset
|
286 typeMap.put("day_interval", Integer.valueOf(Types.NUMERIC)); // New as of Oct2020 release |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
287 typeMap.put("decimal", Integer.valueOf(Types.DECIMAL)); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
288 typeMap.put("double", Integer.valueOf(Types.DOUBLE)); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
289 // typeMap.put("geometry", Integer.valueOf(Types.???)); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
290 // typeMap.put("geometrya", Integer.valueOf(Types.???)); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
291 typeMap.put("hugeint", Integer.valueOf(Types.NUMERIC)); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
292 typeMap.put("inet", Integer.valueOf(Types.VARCHAR)); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
293 typeMap.put("int", Integer.valueOf(Types.INTEGER)); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
294 typeMap.put("json", Integer.valueOf(Types.VARCHAR)); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
295 // typeMap.put("mbr", Integer.valueOf(Types.???)); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
296 typeMap.put("month_interval", Integer.valueOf(Types.INTEGER)); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
297 typeMap.put("oid", Integer.valueOf(Types.BIGINT)); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
298 // typeMap.put("ptr", Integer.valueOf(Types.???)); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
299 typeMap.put("real", Integer.valueOf(Types.REAL)); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
300 typeMap.put("sec_interval", Integer.valueOf(Types.DECIMAL)); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
301 typeMap.put("smallint", Integer.valueOf(Types.SMALLINT)); |
642
dd9b4fb14256
Added recognition of 'xml' type.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
626
diff
changeset
|
302 typeMap.put("str", Integer.valueOf(Types.VARCHAR)); // MonetDB prepare <stmt> uses type 'str' (instead of varchar) for the schema, table and column metadata output. DO NOT REMOVE this entry! |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
303 // typeMap.put("table", Integer.valueOf(Types.???)); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
304 typeMap.put("time", Integer.valueOf(Types.TIME)); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
305 typeMap.put("timestamp", Integer.valueOf(Types.TIMESTAMP)); |
380
bf521f343172
Added support for new Java 8 java.sql.Types: Types.TIME_WITH_TIMEZONE and Types.TIMESTAMP_WITH_TIMEZONE.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
379
diff
changeset
|
306 typeMap.put("timestamptz", Integer.valueOf(Types.TIMESTAMP_WITH_TIMEZONE)); // new in Java 8: Types.TIMESTAMP_WITH_TIMEZONE (value 2014) |
bf521f343172
Added support for new Java 8 java.sql.Types: Types.TIME_WITH_TIMEZONE and Types.TIMESTAMP_WITH_TIMEZONE.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
379
diff
changeset
|
307 typeMap.put("timetz", Integer.valueOf(Types.TIME_WITH_TIMEZONE)); // new in Java 8: Types.TIME_WITH_TIMEZONE (value 2013) |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
308 typeMap.put("tinyint", Integer.valueOf(Types.TINYINT)); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
309 typeMap.put("url", Integer.valueOf(Types.VARCHAR)); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
310 typeMap.put("uuid", Integer.valueOf(Types.VARCHAR)); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
311 typeMap.put("varchar", Integer.valueOf(Types.VARCHAR)); |
642
dd9b4fb14256
Added recognition of 'xml' type.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
626
diff
changeset
|
312 typeMap.put("wrd", Integer.valueOf(Types.BIGINT)); // keep it in for old (pre Dec2016) MonetDB servers |
dd9b4fb14256
Added recognition of 'xml' type.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
626
diff
changeset
|
313 typeMap.put("xml", Integer.valueOf(Types.VARCHAR)); // used when "CREATE TYPE xml EXTERNAL NAME xml;" is executed |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
314 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
315 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
316 /** |
223
e8139dbe3883
Rename internal method MonetDriver.getJavaType() into MonetDriver.getJdbcSQLType()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
317 * Returns the java.sql.Types equivalent of the given MonetDB type name. |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
318 * |
223
e8139dbe3883
Rename internal method MonetDriver.getJavaType() into MonetDriver.getJdbcSQLType()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
319 * @param type the SQL data type name as used by MonetDB |
e8139dbe3883
Rename internal method MonetDriver.getJavaType() into MonetDriver.getJdbcSQLType()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
320 * @return the matching java.sql.Types constant or |
e8139dbe3883
Rename internal method MonetDriver.getJavaType() into MonetDriver.getJdbcSQLType()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
321 * java.sql.Types.OTHER if nothing matched the given type name |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
322 */ |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
262
diff
changeset
|
323 static final int getJdbcSQLType(final String type) { |
223
e8139dbe3883
Rename internal method MonetDriver.getJavaType() into MonetDriver.getJdbcSQLType()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
324 // find the column type name in the typeMap |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
262
diff
changeset
|
325 final Integer tp = typeMap.get(type); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
326 if (tp != null) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
327 return tp.intValue(); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
328 } |
223
e8139dbe3883
Rename internal method MonetDriver.getJavaType() into MonetDriver.getJdbcSQLType()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
329 // When type name is not found in the map, for instance |
e8139dbe3883
Rename internal method MonetDriver.getJavaType() into MonetDriver.getJdbcSQLType()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
330 // when it is a new type (not yet added in the above typeMap) or |
e8139dbe3883
Rename internal method MonetDriver.getJavaType() into MonetDriver.getJdbcSQLType()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
331 // when type name is: any or geometry or geometrya or mbr or ptr or table. |
e8139dbe3883
Rename internal method MonetDriver.getJavaType() into MonetDriver.getJdbcSQLType()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
332 return Types.OTHER; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
333 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
334 |
714
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
335 /** |
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
336 * Returns the Class object for a given java.sql.Types value. |
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
337 * |
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
338 * @param type a value from java.sql.Types |
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
339 * @return a Class object from which an instance would be returned |
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
340 */ |
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
341 static final Class<?> getClassForType(final int type) { |
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
342 /** |
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
343 * This switch returns the types as objects according to table B-3 from |
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
344 * Oracle's JDBC specification 4.1 |
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
345 */ |
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
346 switch(type) { |
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
347 case Types.CHAR: |
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
348 case Types.VARCHAR: |
735
3dd0d43014e8
Disable checks for Types.LONGVARCHAR and Types.LONGVARBINARY as MonetDB server does not support these data types, and no mappings exists to these JDBC Types and thus these cases will never be reached in JDBC Driver.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
349 /* case Types.LONGVARCHAR: // MonetDB doesn't use type LONGVARCHAR */ |
714
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
350 return String.class; |
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
351 case Types.NUMERIC: |
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
352 case Types.DECIMAL: |
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
353 return java.math.BigDecimal.class; |
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
354 case Types.BOOLEAN: |
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
355 return Boolean.class; |
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
356 case Types.TINYINT: |
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
357 case Types.SMALLINT: |
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
358 return Short.class; |
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
359 case Types.INTEGER: |
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
360 return Integer.class; |
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
361 case Types.BIGINT: |
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
362 return Long.class; |
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
363 case Types.REAL: |
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
364 return Float.class; |
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
365 case Types.FLOAT: |
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
366 case Types.DOUBLE: |
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
367 return Double.class; |
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
368 case Types.BINARY: // MonetDB currently does not support these |
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
369 case Types.VARBINARY: // see treat_blob_as_binary property |
735
3dd0d43014e8
Disable checks for Types.LONGVARCHAR and Types.LONGVARBINARY as MonetDB server does not support these data types, and no mappings exists to these JDBC Types and thus these cases will never be reached in JDBC Driver.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
716
diff
changeset
|
370 /* case Types.LONGVARBINARY: // MonetDB doesn't use type LONGVARBINARY */ |
714
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
371 return byte[].class; |
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
372 case Types.DATE: |
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
373 return java.sql.Date.class; |
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
374 case Types.TIME: |
820
4c35009cd59c
In ResultSet.getObject() method added support for retrieving
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
786
diff
changeset
|
375 return java.sql.Time.class; |
714
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
376 case Types.TIME_WITH_TIMEZONE: |
820
4c35009cd59c
In ResultSet.getObject() method added support for retrieving
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
786
diff
changeset
|
377 return java.time.OffsetTime.class; |
714
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
378 case Types.TIMESTAMP: |
820
4c35009cd59c
In ResultSet.getObject() method added support for retrieving
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
786
diff
changeset
|
379 return java.sql.Timestamp.class; |
714
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
380 case Types.TIMESTAMP_WITH_TIMEZONE: |
820
4c35009cd59c
In ResultSet.getObject() method added support for retrieving
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
786
diff
changeset
|
381 return java.time.OffsetDateTime.class; |
714
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
382 case Types.CLOB: |
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
383 return java.sql.Clob.class; |
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
384 case Types.BLOB: |
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
385 return java.sql.Blob.class; |
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
386 |
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
387 // all the rest are currently not implemented and used |
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
388 default: |
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
389 return String.class; |
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
390 } |
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
391 } |
ad7b08ef7745
Moving static method getClassForType() from MonetResulSet to MonetDriver class which is a much more logical place.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
709
diff
changeset
|
392 |
708
5022a57f9d97
Resolve javadoc errors.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
662
diff
changeset
|
393 private static String TypeMapppingSQL; // cache to optimise getSQLTypeMap() |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
394 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
395 * Returns a String usable in an SQL statement to map the server types |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
396 * to values of java.sql.Types using the global static type map. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
397 * The returned string will be a SQL CASE x statement where the x is |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
398 * replaced with the given column name (or expression) string. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
399 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
400 * @param column a String representing the value that should be evaluated |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
401 * in the SQL CASE statement |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
402 * @return a SQL CASE statement |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
403 */ |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
262
diff
changeset
|
404 static final String getSQLTypeMap(final String column) { |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
405 if (TypeMapppingSQL == null) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
406 // first time, compose TypeMappping SQL string |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
262
diff
changeset
|
407 final StringBuilder val = new StringBuilder((typeMap.size() * (7 + 7 + 7 + 4)) + 14); |
8
a27ee2cb14a0
Replace String methods equals("") and "".equals( with isEmpty()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
0
diff
changeset
|
408 for (Entry<String, Integer> entry : typeMap.entrySet()) { |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
409 val.append(" WHEN '").append(entry.getKey()).append("' THEN ").append(entry.getValue().toString()); |
8
a27ee2cb14a0
Replace String methods equals("") and "".equals( with isEmpty()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
0
diff
changeset
|
410 } |
761
e1389c0ffb7c
A few more places where we can remove append() calls for static int values in construction of Strings.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
735
diff
changeset
|
411 val.append(" ELSE " + Types.OTHER + " END"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
412 // as the typeMap is static, cache this SQL part for all next calls |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
413 TypeMapppingSQL = val.toString(); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
414 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
415 return "CASE " + column + TypeMapppingSQL; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
416 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
417 } |