Mercurial > hg > monetdb-java
annotate src/main/java/org/monetdb/jdbc/MonetConnection.java @ 407:40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
author | Martin van Dinther <martin.van.dinther@monetdbsolutions.com> |
---|---|
date | Thu, 07 Jan 2021 19:15:51 +0100 (2021-01-07) |
parents | bf9f6b6ecf40 |
children | 5540793628d6 |
rev | line source |
---|---|
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1 /* |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2 * 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
|
3 * 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
|
4 * 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
|
5 * |
406
bf9f6b6ecf40
Update Copyright year.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
391
diff
changeset
|
6 * Copyright 1997 - July 2008 CWI, August 2008 - 2021 MonetDB B.V. |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
7 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
8 |
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
|
9 package org.monetdb.jdbc; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
10 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
11 import java.io.File; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
12 import java.io.IOException; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
13 import java.net.SocketException; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
14 import java.net.SocketTimeoutException; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
15 import java.sql.CallableStatement; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
16 import java.sql.Connection; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
17 import java.sql.DatabaseMetaData; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
18 import java.sql.PreparedStatement; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
19 import java.sql.ResultSet; |
194
1296dbcc4958
Resolved javadoc many errors and warnings, such as:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
186
diff
changeset
|
20 import java.sql.SQLClientInfoException; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
21 import java.sql.SQLException; |
266
eefa7f625673
Resolve javadoc errors:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
262
diff
changeset
|
22 import java.sql.SQLFeatureNotSupportedException; |
144
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
136
diff
changeset
|
23 import java.sql.SQLNonTransientConnectionException; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
24 import java.sql.SQLWarning; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
25 import java.sql.Savepoint; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
26 import java.sql.Statement; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
27 import java.util.ArrayList; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
28 import java.util.Calendar; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
29 import java.util.HashMap; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
30 import java.util.Map; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
31 import java.util.Map.Entry; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
32 import java.util.Properties; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
33 import java.util.WeakHashMap; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
34 import java.util.concurrent.Executor; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
35 |
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
|
36 import org.monetdb.mcl.io.BufferedMCLReader; |
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
|
37 import org.monetdb.mcl.io.BufferedMCLWriter; |
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
|
38 import org.monetdb.mcl.net.MapiSocket; |
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
|
39 import org.monetdb.mcl.parser.HeaderLineParser; |
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
|
40 import org.monetdb.mcl.parser.MCLParseException; |
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
|
41 import org.monetdb.mcl.parser.StartOfHeaderParser; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
42 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
43 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
44 * A {@link Connection} suitable for the MonetDB database. |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
45 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
46 * This connection represents a connection (session) to a MonetDB |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
47 * database. SQL statements are executed and results are returned within |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
48 * the context of a connection. This Connection object holds a physical |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
49 * connection to the MonetDB database. |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
50 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
51 * A Connection object's database should able to provide information |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
52 * describing its tables, its supported SQL grammar, its stored |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
53 * procedures, the capabilities of this connection, and so on. This |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
54 * information is obtained with the getMetaData method. |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
55 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
56 * Note: By default a Connection object is in auto-commit mode, which |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
57 * means that it automatically commits changes after executing each |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
58 * statement. If auto-commit mode has been disabled, the method commit |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
59 * must be called explicitly in order to commit changes; otherwise, |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
60 * database changes will not be saved. |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
61 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
62 * The current state of this connection is that it nearly implements the |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
63 * whole Connection interface. |
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 * @author Fabian Groffen |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
66 * @author Martin van Dinther |
332
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
67 * @version 1.5 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
68 */ |
164
7c9e386fe49a
As of Java 1.7 implementations of JDBC interfaces Connection, Statement, PreparedStatement,
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
69 public class MonetConnection |
7c9e386fe49a
As of Java 1.7 implementations of JDBC interfaces Connection, Statement, PreparedStatement,
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
70 extends MonetWrapper |
7c9e386fe49a
As of Java 1.7 implementations of JDBC interfaces Connection, Statement, PreparedStatement,
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
71 implements Connection, AutoCloseable |
7c9e386fe49a
As of Java 1.7 implementations of JDBC interfaces Connection, Statement, PreparedStatement,
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
144
diff
changeset
|
72 { |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
73 /** the successful processed input properties */ |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
74 private final Properties conn_props = new Properties(); |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
75 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
76 /** The hostname to connect to */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
77 private final String hostname; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
78 /** The port to connect on the host to */ |
407
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
79 private int port; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
80 /** The database to use (currently not used) */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
81 private final String database; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
82 /** The username to use when authenticating */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
83 private final String username; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
84 /** The password to use when authenticating */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
85 private final String password; |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
86 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
87 /** A connection to mserver5 using a TCP socket */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
88 private final MapiSocket server; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
89 /** The Reader from the server */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
90 private final BufferedMCLReader in; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
91 /** The Writer to the server */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
92 private final BufferedMCLWriter out; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
93 |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
94 /** A StartOfHeaderParser declared for reuse. */ |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
95 private StartOfHeaderParser sohp = new StartOfHeaderParser(); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
96 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
97 /** Whether this Connection is closed (and cannot be used anymore) */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
98 private boolean closed; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
99 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
100 /** Whether this Connection is in autocommit mode */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
101 private boolean autoCommit = true; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
102 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
103 /** The stack of warnings for this Connection object */ |
407
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
104 private SQLWarning warnings; |
284
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
105 |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
106 /** The Connection specific mapping of user defined types to Java types */ |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
107 private Map<String,Class<?>> typeMap = new HashMap<String,Class<?>>() { |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
108 private static final long serialVersionUID = 1L; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
109 { |
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
|
110 put("inet", org.monetdb.jdbc.types.INET.class); |
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
|
111 put("url", org.monetdb.jdbc.types.URL.class); |
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 // See javadoc for documentation about WeakHashMap if you don't know what |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
116 // it does !!!NOW!!! (only when you deal with it of course) |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
117 /** A Map containing all (active) Statements created from this Connection */ |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
118 private WeakHashMap<Statement,?> statements = new WeakHashMap<Statement, Object>(); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
119 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
120 /** The number of results we receive from the server at once */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
121 private int curReplySize = -1; // the server by default uses -1 (all) |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
122 |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
123 /** A template to apply to each query (like pre and post fixes), filled in constructor */ |
336
5826913bdc6d
commandTempl[2] is never used, so no need to allocate and initialise it.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
335
diff
changeset
|
124 // note: it is made public to the package as queryTempl[2] is used from MonetStatement |
332
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
125 final String[] queryTempl = new String[3]; // pre, post, sep |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
126 |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
127 /** A template to apply to each command (like pre and post fixes), filled in constructor */ |
336
5826913bdc6d
commandTempl[2] is never used, so no need to allocate and initialise it.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
335
diff
changeset
|
128 private final String[] commandTempl = new String[2]; // pre, post |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
129 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
130 /** the SQL language */ |
186
4767b005a531
Making variables private where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
184
diff
changeset
|
131 private static final int LANG_SQL = 0; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
132 /** the MAL language (officially *NOT* supported) */ |
186
4767b005a531
Making variables private where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
184
diff
changeset
|
133 private static final int LANG_MAL = 3; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
134 /** an unknown language */ |
186
4767b005a531
Making variables private where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
184
diff
changeset
|
135 private static final int LANG_UNKNOWN = -1; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
136 /** The language which is used */ |
186
4767b005a531
Making variables private where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
184
diff
changeset
|
137 private final int lang; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
138 |
175
8700d9ef2ace
Added possibility via a connection property to let the JDBC driver
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
167
diff
changeset
|
139 /** Whether or not BLOB is mapped to Types.VARBINARY instead of Types.BLOB within this connection */ |
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:
378
diff
changeset
|
140 private boolean treatBlobAsVarBinary = true; |
175
8700d9ef2ace
Added possibility via a connection property to let the JDBC driver
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
167
diff
changeset
|
141 /** Whether or not CLOB is mapped to Types.VARCHAR instead of Types.CLOB within this connection */ |
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:
378
diff
changeset
|
142 private boolean treatClobAsVarChar = true; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
143 |
271
4880267d0fe1
Added implementation of java.sql.CallableStatement interface, test program and updated the ChangeLog and release notes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
266
diff
changeset
|
144 /** The last set query timeout on the server as used by Statement, PreparedStatement and CallableStatement */ |
249
46385d8ff8c9
Improve the implementation of Statement methods getQueryTimeout() and setQueryTimeout().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
243
diff
changeset
|
145 protected int lastSetQueryTimeout = 0; // 0 means no timeout, which is the default on the server |
46385d8ff8c9
Improve the implementation of Statement methods getQueryTimeout() and setQueryTimeout().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
243
diff
changeset
|
146 |
215
71b039bc2d99
Added support for querying the sys.comments table for some meta data methods
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
214
diff
changeset
|
147 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
148 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
149 * Constructor of a Connection for MonetDB. At this moment the |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
150 * current implementation limits itself to storing the given host, |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
151 * database, username and password for later use by the |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
152 * createStatement() call. This constructor is only accessible to |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
153 * classes from the jdbc package. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
154 * |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
155 * @param props a Property hashtable holding the properties needed for connecting |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
156 * @throws SQLException if a database error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
157 * @throws IllegalArgumentException is one of the arguments is null or empty |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
158 */ |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
159 MonetConnection(final Properties props) |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
160 throws SQLException, IllegalArgumentException |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
161 { |
184
e0f76fedafc8
Corrected implementation of Connection.prepareCall() methods. They used to return null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
178
diff
changeset
|
162 // for debug: System.out.println("New connection object. Received properties are: " + props.toString()); |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
163 // get supported property values from the props argument. |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
164 // When a value is found add it to the internal conn_props list for use by getClientInfo(). |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
165 this.hostname = props.getProperty("host"); |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
166 if (this.hostname != null) |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
167 conn_props.setProperty("host", this.hostname); |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
168 |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
169 final String port_prop = props.getProperty("port"); |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
170 if (port_prop != null) { |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
171 try { |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
172 this.port = Integer.parseInt(port_prop); |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
173 } catch (NumberFormatException e) { |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
174 addWarning("Unable to parse port number from: " + port_prop, "M1M05"); |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
175 } |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
176 conn_props.setProperty("port", Integer.toString(this.port)); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
177 } |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
178 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
179 this.database = props.getProperty("database"); |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
180 if (this.database != null) |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
181 conn_props.setProperty("database", this.database); |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
182 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
183 this.username = props.getProperty("user"); |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
184 if (this.username != null) |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
185 conn_props.setProperty("user", this.username); |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
186 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
187 this.password = props.getProperty("password"); |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
188 if (this.password != null) |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
189 conn_props.setProperty("password", this.password); |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
190 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
191 String language = props.getProperty("language"); |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
192 if (language != null) |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
193 conn_props.setProperty("language", language); |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
194 |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
195 boolean debug = false; |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
196 String debug_prop = props.getProperty("debug"); |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
197 if (debug_prop != null) { |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
198 debug = Boolean.parseBoolean(debug_prop); |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
199 conn_props.setProperty("debug", Boolean.toString(debug)); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
200 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
201 |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
202 final String hash = props.getProperty("hash"); |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
203 if (hash != null) |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
204 conn_props.setProperty("hash", hash); |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
205 |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
206 final String treatBlobAsVarBinary_prop = props.getProperty("treat_blob_as_binary"); |
175
8700d9ef2ace
Added possibility via a connection property to let the JDBC driver
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
167
diff
changeset
|
207 if (treatBlobAsVarBinary_prop != null) { |
8700d9ef2ace
Added possibility via a connection property to let the JDBC driver
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
167
diff
changeset
|
208 treatBlobAsVarBinary = Boolean.parseBoolean(treatBlobAsVarBinary_prop); |
8700d9ef2ace
Added possibility via a connection property to let the JDBC driver
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
167
diff
changeset
|
209 conn_props.setProperty("treat_blob_as_binary", Boolean.toString(treatBlobAsVarBinary)); |
178
dd12348c41cf
Improvement: only extend typeMap when the property was set to true.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
175
diff
changeset
|
210 if (treatBlobAsVarBinary) |
dd12348c41cf
Improvement: only extend typeMap when the property was set to true.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
175
diff
changeset
|
211 typeMap.put("blob", Byte[].class); |
175
8700d9ef2ace
Added possibility via a connection property to let the JDBC driver
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
167
diff
changeset
|
212 } |
8700d9ef2ace
Added possibility via a connection property to let the JDBC driver
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
167
diff
changeset
|
213 |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
214 final String treatClobAsVarChar_prop = props.getProperty("treat_clob_as_varchar"); |
175
8700d9ef2ace
Added possibility via a connection property to let the JDBC driver
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
167
diff
changeset
|
215 if (treatClobAsVarChar_prop != null) { |
8700d9ef2ace
Added possibility via a connection property to let the JDBC driver
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
167
diff
changeset
|
216 treatClobAsVarChar = Boolean.parseBoolean(treatClobAsVarChar_prop); |
8700d9ef2ace
Added possibility via a connection property to let the JDBC driver
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
167
diff
changeset
|
217 conn_props.setProperty("treat_clob_as_varchar", Boolean.toString(treatClobAsVarChar)); |
178
dd12348c41cf
Improvement: only extend typeMap when the property was set to true.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
175
diff
changeset
|
218 if (treatClobAsVarChar) |
dd12348c41cf
Improvement: only extend typeMap when the property was set to true.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
175
diff
changeset
|
219 typeMap.put("clob", String.class); |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
220 } |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
221 |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
222 int sockTimeout = 0; |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
223 final String so_timeout_prop = props.getProperty("so_timeout"); |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
224 if (so_timeout_prop != null) { |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
225 try { |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
226 sockTimeout = Integer.parseInt(so_timeout_prop); |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
227 if (sockTimeout < 0) { |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
228 addWarning("Negative socket timeout not allowed. Value ignored", "M1M05"); |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
229 sockTimeout = 0; |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
230 } |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
231 } catch (NumberFormatException e) { |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
232 addWarning("Unable to parse socket timeout number from: " + so_timeout_prop, "M1M05"); |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
233 } |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
234 conn_props.setProperty("so_timeout", Integer.toString(sockTimeout)); |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
235 } |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
236 |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
237 // check mandatory input arguments |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
238 if (hostname == null || hostname.isEmpty()) |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
239 throw new IllegalArgumentException("Missing or empty host name"); |
225
5ddb1f20d5d5
Socket may also throw an UnknownHostException. Add it to MapiSocket.connect() and catch it in MonetConnection(Properties props).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
219
diff
changeset
|
240 if (port <= 0 || port > 65535) |
348
bcb9a99d399d
Add private checkNotClosed() method to check if the connection is not closed.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
345
diff
changeset
|
241 throw new IllegalArgumentException("Invalid port number: " + port |
bcb9a99d399d
Add private checkNotClosed() method to check if the connection is not closed.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
345
diff
changeset
|
242 + ". It should not be " + (port < 0 ? "negative" : (port > 65535 ? "larger than 65535" : "0"))); |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
243 if (username == null || username.isEmpty()) |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
244 throw new IllegalArgumentException("Missing or empty user name"); |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
245 if (password == null || password.isEmpty()) |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
246 throw new IllegalArgumentException("Missing or empty password"); |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
247 if (language == null || language.isEmpty()) { |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
248 // fallback to default language: sql |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
249 language = "sql"; |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
250 addWarning("No language specified, defaulting to 'sql'", "M1M05"); |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
251 } |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
252 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
253 server = new MapiSocket(); |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
254 if (hash != null) |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
255 server.setHash(hash); |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
256 if (database != null) |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
257 server.setDatabase(database); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
258 server.setLanguage(language); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
259 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
260 // we're debugging here... uhm, should be off in real life |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
261 if (debug) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
262 try { |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
263 final String fname = props.getProperty("logfile", "monet_" + System.currentTimeMillis() + ".log"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
264 File f = new File(fname); |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
265 |
25
5ec116ba7d71
When single character use faster version of indexOf(<char>)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
8
diff
changeset
|
266 int ext = fname.lastIndexOf('.'); |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
267 if (ext < 0) |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
268 ext = fname.length(); |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
269 final String pre = fname.substring(0, ext); |
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
270 final String suf = fname.substring(ext); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
271 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
272 for (int i = 1; f.exists(); i++) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
273 f = new File(pre + "-" + i + suf); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
274 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
275 |
278
1d6062d94377
Reduce duplicate code.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
271
diff
changeset
|
276 server.debug(f.getAbsolutePath()); // enable logging on the MapiSocket level |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
277 } catch (IOException ex) { |
144
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
136
diff
changeset
|
278 throw new SQLNonTransientConnectionException("Opening logfile failed: " + ex.getMessage(), "08M01"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
279 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
280 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
281 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
282 try { |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
283 final java.util.List<String> warnings = server.connect(hostname, port, username, password); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
284 for (String warning : warnings) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
285 addWarning(warning, "01M02"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
286 } |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
287 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
288 // apply NetworkTimeout value from legacy (pre 4.1) driver |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
289 // so_timeout calls |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
290 server.setSoTimeout(sockTimeout); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
291 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
292 in = server.getReader(); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
293 out = server.getWriter(); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
294 |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
295 final String error = in.waitForPrompt(); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
296 if (error != null) |
144
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
136
diff
changeset
|
297 throw new SQLNonTransientConnectionException((error.length() > 6) ? error.substring(6) : error, "08001"); |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
298 } catch (java.net.UnknownHostException e) { |
225
5ddb1f20d5d5
Socket may also throw an UnknownHostException. Add it to MapiSocket.connect() and catch it in MonetConnection(Properties props).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
219
diff
changeset
|
299 throw new SQLNonTransientConnectionException("Unknown Host (" + hostname + "): " + e.getMessage(), "08006"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
300 } catch (IOException e) { |
144
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
136
diff
changeset
|
301 throw new SQLNonTransientConnectionException("Unable to connect (" + hostname + ":" + port + "): " + e.getMessage(), "08006"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
302 } catch (MCLParseException e) { |
144
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
136
diff
changeset
|
303 throw new SQLNonTransientConnectionException(e.getMessage(), "08001"); |
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
|
304 } catch (org.monetdb.mcl.MCLException e) { |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
305 final String[] connex = e.getMessage().split("\n"); |
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
306 final SQLException sqle = new SQLNonTransientConnectionException(connex[0], "08001", e); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
307 for (int i = 1; i < connex.length; i++) { |
144
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
136
diff
changeset
|
308 sqle.setNextException(new SQLNonTransientConnectionException(connex[1], "08001")); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
309 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
310 throw sqle; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
311 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
312 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
313 // we seem to have managed to log in, let's store the |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
314 // language used and language specific query templates |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
315 if ("sql".equals(language)) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
316 lang = LANG_SQL; |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
317 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
318 queryTempl[0] = "s"; // pre |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
319 queryTempl[1] = "\n;"; // post |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
320 queryTempl[2] = "\n;\n"; // separator |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
321 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
322 commandTempl[0] = "X"; // pre |
332
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
323 commandTempl[1] = ""; // post |
336
5826913bdc6d
commandTempl[2] is never used, so no need to allocate and initialise it.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
335
diff
changeset
|
324 //commandTempl[2] = "\nX"; // separator (is not used) |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
325 } else if ("mal".equals(language)) { |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
326 lang = LANG_MAL; |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
327 |
332
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
328 queryTempl[0] = ""; // pre |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
329 queryTempl[1] = ";\n"; // post |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
330 queryTempl[2] = ";\n"; // separator |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
331 |
332
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
332 commandTempl[0] = ""; // pre |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
333 commandTempl[1] = ""; // post |
336
5826913bdc6d
commandTempl[2] is never used, so no need to allocate and initialise it.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
335
diff
changeset
|
334 //commandTempl[2] = ""; // separator (is not used) |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
335 } else { |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
336 lang = LANG_UNKNOWN; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
337 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
338 |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
339 // the following initialisers are only valid when the language is SQL... |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
340 if (lang == LANG_SQL) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
341 // enable auto commit |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
342 setAutoCommit(true); |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
343 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
344 // set our time zone on the server |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
345 final Calendar cal = Calendar.getInstance(); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
346 int offset = cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
347 offset /= (60 * 1000); // milliseconds to minutes |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
348 String tz = offset < 0 ? "-" : "+"; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
349 tz += (Math.abs(offset) / 60 < 10 ? "0" : "") + (Math.abs(offset) / 60) + ":"; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
350 offset -= (offset / 60) * 60; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
351 tz += (offset < 10 ? "0" : "") + offset; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
352 sendIndependentCommand("SET TIME ZONE INTERVAL '" + tz + "' HOUR TO MINUTE"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
353 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
354 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
355 // we're absolutely not closed, since we're brand new |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
356 closed = false; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
357 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
358 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
359 //== methods of interface Connection |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
360 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
361 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
362 * Clears all warnings reported for this Connection object. After a |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
363 * call to this method, the method getWarnings returns null until a |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
364 * new warning is reported for this Connection object. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
365 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
366 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
367 public void clearWarnings() { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
368 warnings = null; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
369 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
370 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
371 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
372 * Releases this Connection object's database and JDBC resources |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
373 * immediately instead of waiting for them to be automatically |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
374 * released. All Statements created from this Connection will be |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
375 * closed when this method is called. |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
376 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
377 * Calling the method close on a Connection object that is already |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
378 * closed is a no-op. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
379 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
380 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
381 public void close() { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
382 synchronized (server) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
383 for (Statement st : statements.keySet()) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
384 try { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
385 st.close(); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
386 } catch (SQLException e) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
387 // better luck next time! |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
388 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
389 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
390 // close the socket |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
391 server.close(); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
392 // report ourselves as closed |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
393 closed = true; |
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 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
396 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
397 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
398 * Makes all changes made since the previous commit/rollback |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
399 * permanent and releases any database locks currently held by this |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
400 * Connection object. This method should be used only when |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
401 * auto-commit mode has been disabled. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
402 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
403 * @throws SQLException if a database access error occurs or this |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
404 * Connection object is in auto-commit mode |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
405 * @see #setAutoCommit(boolean) |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
406 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
407 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
408 public void commit() throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
409 // note: can't use sendIndependentCommand here because we need |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
410 // to process the auto_commit state the server gives |
77
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
411 sendTransactionCommand("COMMIT"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
412 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
413 |
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 * Creates a Statement object for sending SQL statements to the |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
416 * database. SQL statements without parameters are normally |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
417 * executed using Statement objects. If the same SQL statement is |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
418 * executed many times, it may be more efficient to use a |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
419 * PreparedStatement object. |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
420 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
421 * Result sets created using the returned Statement object will by |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
422 * default be type TYPE_FORWARD_ONLY and have a concurrency level of |
292
b127164342c4
Introduce default general behavior settings DEF_... for MonetResultSets and use them
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
288
diff
changeset
|
423 * CONCUR_READ_ONLY and a holdability of HOLD_CURSORS_OVER_COMMIT. |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
424 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
425 * @return a new default Statement object |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
426 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
427 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
428 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
429 public Statement createStatement() throws SQLException { |
292
b127164342c4
Introduce default general behavior settings DEF_... for MonetResultSets and use them
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
288
diff
changeset
|
430 return createStatement(MonetResultSet.DEF_RESULTSETTYPE, MonetResultSet.DEF_CONCURRENCY, MonetResultSet.DEF_HOLDABILITY); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
431 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
432 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
433 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
434 * Creates a Statement object that will generate ResultSet objects |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
435 * with the given type and concurrency. This method is the same as |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
436 * the createStatement method above, but it allows the default |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
437 * result set type and concurrency to be overridden. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
438 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
439 * @param resultSetType a result set type; one of |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
440 * ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
441 * or ResultSet.TYPE_SCROLL_SENSITIVE |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
442 * @param resultSetConcurrency a concurrency type; one of |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
443 * ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
444 * @return a new Statement object that will generate ResultSet objects with |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
445 * the given type and concurrency |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
446 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
447 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
448 @Override |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
449 public Statement createStatement(final int resultSetType, final int resultSetConcurrency) throws SQLException { |
292
b127164342c4
Introduce default general behavior settings DEF_... for MonetResultSets and use them
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
288
diff
changeset
|
450 return createStatement(resultSetType, resultSetConcurrency, MonetResultSet.DEF_HOLDABILITY); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
451 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
452 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
453 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
454 * Creates a Statement object that will generate ResultSet objects |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
455 * with the given type, concurrency, and holdability. This method |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
456 * is the same as the createStatement method above, but it allows |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
457 * the default result set type, concurrency, and holdability to be |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
458 * overridden. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
459 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
460 * @param resultSetType one of the following ResultSet constants: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
461 * ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
462 * or ResultSet.TYPE_SCROLL_SENSITIVE |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
463 * @param resultSetConcurrency one of the following ResultSet |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
464 * constants: ResultSet.CONCUR_READ_ONLY or |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
465 * ResultSet.CONCUR_UPDATABLE |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
466 * @param resultSetHoldability one of the following ResultSet |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
467 * constants: ResultSet.HOLD_CURSORS_OVER_COMMIT or |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
468 * ResultSet.CLOSE_CURSORS_AT_COMMIT |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
469 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
470 * @return a new Statement object that will generate ResultSet |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
471 * objects with the given type, concurrency, and holdability |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
472 * @throws SQLException if a database access error occurs or the |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
473 * given parameters are not ResultSet constants indicating type, |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
474 * concurrency, and holdability |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
475 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
476 @Override |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
477 public Statement createStatement(final int resultSetType, final int resultSetConcurrency, final int resultSetHoldability) throws SQLException { |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
478 try { |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
479 final Statement ret = new MonetStatement(this, resultSetType, resultSetConcurrency, resultSetHoldability); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
480 // store it in the map for when we close... |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
481 statements.put(ret, null); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
482 return ret; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
483 } catch (IllegalArgumentException e) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
484 throw new SQLException(e.toString(), "M0M03"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
485 } |
271
4880267d0fe1
Added implementation of java.sql.CallableStatement interface, test program and updated the ChangeLog and release notes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
266
diff
changeset
|
486 // we don't have to catch SQLException because that is declared to be thrown |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
487 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
488 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
489 /** |
77
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
490 * Retrieves the current auto-commit mode for this Connection object. |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
491 * |
77
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
492 * @return the current state of this Connection object's auto-commit mode |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
493 * @see #setAutoCommit(boolean) |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
494 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
495 @Override |
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
|
496 public boolean getAutoCommit() { |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
497 return autoCommit; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
498 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
499 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
500 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
501 * Retrieves this Connection object's current catalog name. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
502 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
503 * @return the current catalog name or null if there is none |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
504 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
505 @Override |
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
|
506 public String getCatalog() { |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
507 // MonetDB does NOT support catalogs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
508 return null; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
509 } |
77
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
510 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
511 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
512 * Retrieves the current holdability of ResultSet objects created |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
513 * using this Connection object. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
514 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
515 * @return the holdability, one of |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
516 * ResultSet.HOLD_CURSORS_OVER_COMMIT or |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
517 * ResultSet.CLOSE_CURSORS_AT_COMMIT |
194
1296dbcc4958
Resolved javadoc many errors and warnings, such as:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
186
diff
changeset
|
518 * @see #setHoldability(int) |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
519 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
520 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
521 public int getHoldability() { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
522 // TODO: perhaps it is better to have the server implement |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
523 // CLOSE_CURSORS_AT_COMMIT |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
524 return ResultSet.HOLD_CURSORS_OVER_COMMIT; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
525 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
526 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
527 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
528 * Retrieves a DatabaseMetaData object that contains metadata about |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
529 * the database to which this Connection object represents a |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
530 * connection. The metadata includes information about the |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
531 * database's tables, its supported SQL grammar, its stored |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
532 * procedures, the capabilities of this connection, and so on. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
533 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
534 * @throws SQLException if the current language is not SQL |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
535 * @return a DatabaseMetaData object for this Connection object |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
536 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
537 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
538 public DatabaseMetaData getMetaData() throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
539 if (lang != LANG_SQL) |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
540 throw new SQLException("This method is only supported in SQL mode", "M0M04"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
541 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
542 return new MonetDatabaseMetaData(this); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
543 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
544 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
545 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
546 * Retrieves this Connection object's current transaction isolation |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
547 * level. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
548 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
549 * @return the current transaction isolation level, which will be |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
550 * Connection.TRANSACTION_SERIALIZABLE |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
551 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
552 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
553 public int getTransactionIsolation() { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
554 return TRANSACTION_SERIALIZABLE; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
555 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
556 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
557 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
558 * Retrieves the Map object associated with this Connection object. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
559 * Unless the application has added an entry, the type map returned |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
560 * will be empty. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
561 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
562 * @return the java.util.Map object associated with this Connection |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
563 * object |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
564 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
565 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
566 public Map<String,Class<?>> getTypeMap() { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
567 return typeMap; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
568 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
569 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
570 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
571 * Retrieves the first warning reported by calls on this Connection |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
572 * object. If there is more than one warning, subsequent warnings |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
573 * will be chained to the first one and can be retrieved by calling |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
574 * the method SQLWarning.getNextWarning on the warning that was |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
575 * retrieved previously. |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
576 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
577 * This method may not be called on a closed connection; doing so |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
578 * will cause an SQLException to be thrown. |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
579 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
580 * Note: Subsequent warnings will be chained to this SQLWarning. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
581 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
582 * @return the first SQLWarning object or null if there are none |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
583 * @throws SQLException if a database access error occurs or this method is |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
584 * called on a closed connection |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
585 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
586 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
587 public SQLWarning getWarnings() throws SQLException { |
348
bcb9a99d399d
Add private checkNotClosed() method to check if the connection is not closed.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
345
diff
changeset
|
588 checkNotClosed(); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
589 // if there are no warnings, this will be null, which fits with the |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
590 // specification. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
591 return warnings; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
592 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
593 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
594 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
595 * Retrieves whether this Connection object has been closed. A |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
596 * connection is closed if the method close has been called on it or |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
597 * if certain fatal errors have occurred. This method is guaranteed |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
598 * to return true only when it is called after the method |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
599 * Connection.close has been called. |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
600 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
601 * This method generally cannot be called to determine whether a |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
602 * connection to a database is valid or invalid. A typical client |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
603 * can determine that a connection is invalid by catching any |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
604 * exceptions that might be thrown when an operation is attempted. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
605 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
606 * @return true if this Connection object is closed; false if it is |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
607 * still open |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
608 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
609 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
610 public boolean isClosed() { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
611 return closed; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
612 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
613 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
614 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
615 * Retrieves whether this Connection object is in read-only mode. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
616 * MonetDB currently doesn't support updateable result sets, but |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
617 * updates are possible. Hence the Connection object is never in |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
618 * read-only mode. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
619 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
620 * @return true if this Connection object is read-only; false otherwise |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
621 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
622 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
623 public boolean isReadOnly() { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
624 return false; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
625 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
626 |
184
e0f76fedafc8
Corrected implementation of Connection.prepareCall() methods. They used to return null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
178
diff
changeset
|
627 /** |
e0f76fedafc8
Corrected implementation of Connection.prepareCall() methods. They used to return null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
178
diff
changeset
|
628 * Converts the given SQL statement into the system's native SQL grammar. |
e0f76fedafc8
Corrected implementation of Connection.prepareCall() methods. They used to return null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
178
diff
changeset
|
629 * A driver may convert the JDBC SQL grammar into its system's native SQL grammar prior to sending it. |
e0f76fedafc8
Corrected implementation of Connection.prepareCall() methods. They used to return null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
178
diff
changeset
|
630 * This method returns the native form of the statement that the driver would have sent. |
e0f76fedafc8
Corrected implementation of Connection.prepareCall() methods. They used to return null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
178
diff
changeset
|
631 * |
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
|
632 * @param sql - an SQL statement that may contain one or more '?' parameter placeholders. |
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
|
633 * @return the native form of this statement |
184
e0f76fedafc8
Corrected implementation of Connection.prepareCall() methods. They used to return null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
178
diff
changeset
|
634 */ |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
635 @Override |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
636 public String nativeSQL(final String sql) { |
77
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
637 /* there is currently no way to get the native MonetDB rewritten SQL string back, so just return the original string */ |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
638 /* in future we may replace/remove the escape sequences { <escape-type> ...} before sending it to the server */ |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
639 return sql; |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
640 } |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
641 |
184
e0f76fedafc8
Corrected implementation of Connection.prepareCall() methods. They used to return null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
178
diff
changeset
|
642 /** |
e0f76fedafc8
Corrected implementation of Connection.prepareCall() methods. They used to return null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
178
diff
changeset
|
643 * Creates a CallableStatement object for calling database stored procedures. |
e0f76fedafc8
Corrected implementation of Connection.prepareCall() methods. They used to return null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
178
diff
changeset
|
644 * The CallableStatement object provides methods for setting up its IN and OUT parameters, |
e0f76fedafc8
Corrected implementation of Connection.prepareCall() methods. They used to return null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
178
diff
changeset
|
645 * and methods for executing the call to a stored procedure. |
e0f76fedafc8
Corrected implementation of Connection.prepareCall() methods. They used to return null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
178
diff
changeset
|
646 * |
e0f76fedafc8
Corrected implementation of Connection.prepareCall() methods. They used to return null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
178
diff
changeset
|
647 * Note: This method is optimized for handling stored procedure call statements. |
e0f76fedafc8
Corrected implementation of Connection.prepareCall() methods. They used to return null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
178
diff
changeset
|
648 * Some drivers may send the call statement to the database when the method prepareCall is done; |
e0f76fedafc8
Corrected implementation of Connection.prepareCall() methods. They used to return null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
178
diff
changeset
|
649 * others may wait until the CallableStatement object is executed. This has no direct effect |
e0f76fedafc8
Corrected implementation of Connection.prepareCall() methods. They used to return null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
178
diff
changeset
|
650 * on users; however, it does affect which method throws certain SQLExceptions. |
e0f76fedafc8
Corrected implementation of Connection.prepareCall() methods. They used to return null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
178
diff
changeset
|
651 * |
e0f76fedafc8
Corrected implementation of Connection.prepareCall() methods. They used to return null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
178
diff
changeset
|
652 * Result sets created using the returned CallableStatement object will by default be type TYPE_FORWARD_ONLY |
e0f76fedafc8
Corrected implementation of Connection.prepareCall() methods. They used to return null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
178
diff
changeset
|
653 * and have a concurrency level of CONCUR_READ_ONLY. |
e0f76fedafc8
Corrected implementation of Connection.prepareCall() methods. They used to return null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
178
diff
changeset
|
654 * The holdability of the created result sets can be determined by calling getHoldability(). |
e0f76fedafc8
Corrected implementation of Connection.prepareCall() methods. They used to return null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
178
diff
changeset
|
655 * |
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
|
656 * @param sql - an SQL statement that may contain one or more '?' parameter placeholders. |
184
e0f76fedafc8
Corrected implementation of Connection.prepareCall() methods. They used to return null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
178
diff
changeset
|
657 * Typically this statement is specified using JDBC call escape syntax. |
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
|
658 * @return a new default CallableStatement object containing the pre-compiled SQL statement |
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
|
659 * @throws SQLException - if a database access error occurs or this method is called on a closed connection |
184
e0f76fedafc8
Corrected implementation of Connection.prepareCall() methods. They used to return null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
178
diff
changeset
|
660 */ |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
661 @Override |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
662 public CallableStatement prepareCall(final String sql) throws SQLException { |
292
b127164342c4
Introduce default general behavior settings DEF_... for MonetResultSets and use them
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
288
diff
changeset
|
663 return prepareCall(sql, MonetResultSet.DEF_RESULTSETTYPE, MonetResultSet.DEF_CONCURRENCY, MonetResultSet.DEF_HOLDABILITY); |
77
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
664 } |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
665 |
184
e0f76fedafc8
Corrected implementation of Connection.prepareCall() methods. They used to return null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
178
diff
changeset
|
666 /** |
e0f76fedafc8
Corrected implementation of Connection.prepareCall() methods. They used to return null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
178
diff
changeset
|
667 * Creates a CallableStatement object that will generate ResultSet objects with the given type and concurrency. |
e0f76fedafc8
Corrected implementation of Connection.prepareCall() methods. They used to return null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
178
diff
changeset
|
668 * This method is the same as the prepareCall method above, but it allows the default result set type and concurrency to be overridden. |
e0f76fedafc8
Corrected implementation of Connection.prepareCall() methods. They used to return null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
178
diff
changeset
|
669 * The holdability of the created result sets can be determined by calling getHoldability(). |
e0f76fedafc8
Corrected implementation of Connection.prepareCall() methods. They used to return null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
178
diff
changeset
|
670 * |
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
|
671 * @param sql - a String object that is the SQL statement to be sent to the database; may contain on or more '?' parameters |
184
e0f76fedafc8
Corrected implementation of Connection.prepareCall() methods. They used to return null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
178
diff
changeset
|
672 * Typically this statement is specified using JDBC call escape syntax. |
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
|
673 * @param resultSetType - a result set type; one of ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVE |
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
|
674 * @param resultSetConcurrency - a concurrency type; one of ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE |
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
|
675 * @return a new CallableStatement object containing the pre-compiled SQL statement that |
184
e0f76fedafc8
Corrected implementation of Connection.prepareCall() methods. They used to return null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
178
diff
changeset
|
676 * will produce ResultSet objects with the given type and concurrency |
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
|
677 * @throws SQLException - if a database access error occurs, this method is called on a closed connection or |
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
|
678 * the given parameters are not ResultSet constants indicating type and concurrency |
184
e0f76fedafc8
Corrected implementation of Connection.prepareCall() methods. They used to return null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
178
diff
changeset
|
679 */ |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
680 @Override |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
681 public CallableStatement prepareCall(final String sql, final int resultSetType, final int resultSetConcurrency) throws SQLException { |
292
b127164342c4
Introduce default general behavior settings DEF_... for MonetResultSets and use them
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
288
diff
changeset
|
682 return prepareCall(sql, resultSetType, resultSetConcurrency, MonetResultSet.DEF_HOLDABILITY); |
77
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
683 } |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
684 |
184
e0f76fedafc8
Corrected implementation of Connection.prepareCall() methods. They used to return null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
178
diff
changeset
|
685 /** |
e0f76fedafc8
Corrected implementation of Connection.prepareCall() methods. They used to return null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
178
diff
changeset
|
686 * Creates a CallableStatement object that will generate ResultSet objects with the given type and concurrency. |
e0f76fedafc8
Corrected implementation of Connection.prepareCall() methods. They used to return null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
178
diff
changeset
|
687 * This method is the same as the prepareCall method above, but it allows the default result set type, result set concurrency type and holdability to be overridden. |
e0f76fedafc8
Corrected implementation of Connection.prepareCall() methods. They used to return null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
178
diff
changeset
|
688 * |
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
|
689 * @param sql - a String object that is the SQL statement to be sent to the database; may contain on or more '?' parameters |
184
e0f76fedafc8
Corrected implementation of Connection.prepareCall() methods. They used to return null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
178
diff
changeset
|
690 * Typically this statement is specified using JDBC call escape syntax. |
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
|
691 * @param resultSetType - a result set type; one of ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVE |
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
|
692 * @param resultSetConcurrency - a concurrency type; one of ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE |
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
|
693 * @param resultSetHoldability - one of the following ResultSet constants: ResultSet.HOLD_CURSORS_OVER_COMMIT or ResultSet.CLOSE_CURSORS_AT_COMMIT |
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
|
694 * @return a new CallableStatement object, containing the pre-compiled SQL statement, that will generate ResultSet objects with the given type, concurrency, and holdability |
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
|
695 * @throws SQLException - if a database access error occurs, this method is called on a closed connection or |
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
|
696 * the given parameters are not ResultSet constants indicating type, concurrency, and holdability |
184
e0f76fedafc8
Corrected implementation of Connection.prepareCall() methods. They used to return null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
178
diff
changeset
|
697 */ |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
698 @Override |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
699 public CallableStatement prepareCall(final String sql, final int resultSetType, final int resultSetConcurrency, final int resultSetHoldability) |
184
e0f76fedafc8
Corrected implementation of Connection.prepareCall() methods. They used to return null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
178
diff
changeset
|
700 throws SQLException |
e0f76fedafc8
Corrected implementation of Connection.prepareCall() methods. They used to return null.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
178
diff
changeset
|
701 { |
348
bcb9a99d399d
Add private checkNotClosed() method to check if the connection is not closed.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
345
diff
changeset
|
702 checkNotClosed(); |
271
4880267d0fe1
Added implementation of java.sql.CallableStatement interface, test program and updated the ChangeLog and release notes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
266
diff
changeset
|
703 try { |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
704 final CallableStatement ret = new MonetCallableStatement( |
271
4880267d0fe1
Added implementation of java.sql.CallableStatement interface, test program and updated the ChangeLog and release notes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
266
diff
changeset
|
705 this, |
4880267d0fe1
Added implementation of java.sql.CallableStatement interface, test program and updated the ChangeLog and release notes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
266
diff
changeset
|
706 resultSetType, |
4880267d0fe1
Added implementation of java.sql.CallableStatement interface, test program and updated the ChangeLog and release notes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
266
diff
changeset
|
707 resultSetConcurrency, |
4880267d0fe1
Added implementation of java.sql.CallableStatement interface, test program and updated the ChangeLog and release notes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
266
diff
changeset
|
708 resultSetHoldability, |
4880267d0fe1
Added implementation of java.sql.CallableStatement interface, test program and updated the ChangeLog and release notes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
266
diff
changeset
|
709 sql |
4880267d0fe1
Added implementation of java.sql.CallableStatement interface, test program and updated the ChangeLog and release notes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
266
diff
changeset
|
710 ); |
4880267d0fe1
Added implementation of java.sql.CallableStatement interface, test program and updated the ChangeLog and release notes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
266
diff
changeset
|
711 // store it in the map for when we close... |
4880267d0fe1
Added implementation of java.sql.CallableStatement interface, test program and updated the ChangeLog and release notes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
266
diff
changeset
|
712 statements.put(ret, null); |
4880267d0fe1
Added implementation of java.sql.CallableStatement interface, test program and updated the ChangeLog and release notes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
266
diff
changeset
|
713 return ret; |
4880267d0fe1
Added implementation of java.sql.CallableStatement interface, test program and updated the ChangeLog and release notes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
266
diff
changeset
|
714 } catch (IllegalArgumentException e) { |
4880267d0fe1
Added implementation of java.sql.CallableStatement interface, test program and updated the ChangeLog and release notes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
266
diff
changeset
|
715 throw new SQLException(e.toString(), "M0M03"); |
4880267d0fe1
Added implementation of java.sql.CallableStatement interface, test program and updated the ChangeLog and release notes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
266
diff
changeset
|
716 } |
4880267d0fe1
Added implementation of java.sql.CallableStatement interface, test program and updated the ChangeLog and release notes.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
266
diff
changeset
|
717 // we don't have to catch SQLException because that is declared to be thrown |
77
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
718 } |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
719 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
720 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
721 * Creates a PreparedStatement object for sending parameterized SQL |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
722 * statements to the database. |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
723 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
724 * A SQL statement with or without IN parameters can be pre-compiled |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
725 * and stored in a PreparedStatement object. This object can then be |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
726 * used to efficiently execute this statement multiple times. |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
727 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
728 * Note: This method is optimized for handling parametric SQL |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
729 * statements that benefit from precompilation. If the driver |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
730 * supports precompilation, the method prepareStatement will send |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
731 * the statement to the database for precompilation. Some drivers |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
732 * may not support precompilation. In this case, the statement may |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
733 * not be sent to the database until the PreparedStatement object is |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
734 * executed. This has no direct effect on users; however, it does |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
735 * affect which methods throw certain SQLException objects. |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
736 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
737 * Result sets created using the returned PreparedStatement object |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
738 * will by default be type TYPE_FORWARD_ONLY and have a concurrency |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
739 * level of CONCUR_READ_ONLY. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
740 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
741 * @param sql an SQL statement that may contain one or more '?' IN |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
742 * parameter placeholders |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
743 * @return a new default PreparedStatement object containing the |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
744 * pre-compiled SQL statement |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
745 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
746 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
747 @Override |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
748 public PreparedStatement prepareStatement(final String sql) throws SQLException { |
292
b127164342c4
Introduce default general behavior settings DEF_... for MonetResultSets and use them
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
288
diff
changeset
|
749 return prepareStatement(sql, MonetResultSet.DEF_RESULTSETTYPE, MonetResultSet.DEF_CONCURRENCY, MonetResultSet.DEF_HOLDABILITY); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
750 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
751 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
752 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
753 * Creates a PreparedStatement object that will generate ResultSet |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
754 * objects with the given type and concurrency. This method is the |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
755 * same as the prepareStatement method above, but it allows the |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
756 * default result set type and concurrency to be overridden. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
757 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
758 * @param sql a String object that is the SQL statement to be sent to the |
144
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
136
diff
changeset
|
759 * database; may contain one or more ? IN parameters |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
760 * @param resultSetType a result set type; one of |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
761 * ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
762 * or ResultSet.TYPE_SCROLL_SENSITIVE |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
763 * @param resultSetConcurrency a concurrency type; one of |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
764 * ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
765 * @return a new PreparedStatement object containing the pre-compiled SQL |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
766 * statement that will produce ResultSet objects with the given |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
767 * type and concurrency |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
768 * @throws SQLException if a database access error occurs or the given |
144
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
136
diff
changeset
|
769 * parameters are not ResultSet constants indicating |
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
136
diff
changeset
|
770 * type and concurrency |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
771 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
772 @Override |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
773 public PreparedStatement prepareStatement(final String sql, final int resultSetType, final int resultSetConcurrency) throws SQLException { |
292
b127164342c4
Introduce default general behavior settings DEF_... for MonetResultSets and use them
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
288
diff
changeset
|
774 return prepareStatement(sql, resultSetType, resultSetConcurrency, MonetResultSet.DEF_HOLDABILITY); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
775 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
776 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
777 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
778 * Creates a PreparedStatement object that will generate ResultSet |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
779 * objects with the given type, concurrency, and holdability. |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
780 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
781 * This method is the same as the prepareStatement method above, but |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
782 * it allows the default result set type, concurrency, and |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
783 * holdability to be overridden. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
784 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
785 * @param sql a String object that is the SQL statement to be sent |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
786 * to the database; may contain one or more ? IN parameters |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
787 * @param resultSetType one of the following ResultSet constants: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
788 * ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
789 * or ResultSet.TYPE_SCROLL_SENSITIVE |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
790 * @param resultSetConcurrency one of the following ResultSet |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
791 * constants: ResultSet.CONCUR_READ_ONLY or |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
792 * ResultSet.CONCUR_UPDATABLE |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
793 * @param resultSetHoldability one of the following ResultSet |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
794 * constants: ResultSet.HOLD_CURSORS_OVER_COMMIT or |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
795 * ResultSet.CLOSE_CURSORS_AT_COMMIT |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
796 * @return a new PreparedStatement object, containing the |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
797 * pre-compiled SQL statement, that will generate ResultSet objects |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
798 * with the given type, concurrency, and holdability |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
799 * @throws SQLException if a database access error occurs or the |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
800 * given parameters are not ResultSet constants indicating type, |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
801 * concurrency, and holdability |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
802 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
803 @Override |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
804 public PreparedStatement prepareStatement(final String sql, final int resultSetType, final int resultSetConcurrency, final int resultSetHoldability) |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
805 throws SQLException |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
806 { |
348
bcb9a99d399d
Add private checkNotClosed() method to check if the connection is not closed.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
345
diff
changeset
|
807 checkNotClosed(); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
808 try { |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
809 final PreparedStatement ret = new MonetPreparedStatement( |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
810 this, |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
811 resultSetType, |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
812 resultSetConcurrency, |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
813 resultSetHoldability, |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
814 sql |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
815 ); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
816 // store it in the map for when we close... |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
817 statements.put(ret, null); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
818 return ret; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
819 } catch (IllegalArgumentException e) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
820 throw new SQLException(e.toString(), "M0M03"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
821 } |
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
|
822 // we don't have to catch SQLException because that is declared to be thrown |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
823 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
824 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
825 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
826 * Creates a default PreparedStatement object that has the |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
827 * capability to retrieve auto-generated keys. The given constant |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
828 * tells the driver whether it should make auto-generated keys |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
829 * available for retrieval. This parameter is ignored if the SQL |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
830 * statement is not an INSERT statement. |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
831 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
832 * Note: This method is optimized for handling parametric SQL |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
833 * statements that benefit from precompilation. If the driver |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
834 * supports precompilation, the method prepareStatement will send |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
835 * the statement to the database for precompilation. Some drivers |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
836 * may not support precompilation. In this case, the statement may |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
837 * not be sent to the database until the PreparedStatement object is |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
838 * executed. This has no direct effect on users; however, it does |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
839 * affect which methods throw certain SQLExceptions. |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
840 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
841 * Result sets created using the returned PreparedStatement object |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
842 * will by default be type TYPE_FORWARD_ONLY and have a concurrency |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
843 * level of CONCUR_READ_ONLY. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
844 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
845 * @param sql an SQL statement that may contain one or more '?' IN |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
846 * parameter placeholders |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
847 * @param autoGeneratedKeys a flag indicating whether auto-generated |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
848 * keys should be returned; one of |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
849 * Statement.RETURN_GENERATED_KEYS or |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
850 * Statement.NO_GENERATED_KEYS |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
851 * @return a new PreparedStatement object, containing the |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
852 * pre-compiled SQL statement, that will have the capability |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
853 * of returning auto-generated keys |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
854 * @throws SQLException - if a database access error occurs or the |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
855 * given parameter is not a Statement constant indicating |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
856 * whether auto-generated keys should be returned |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
857 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
858 @Override |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
859 public PreparedStatement prepareStatement(final String sql, final int autoGeneratedKeys) throws SQLException { |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
860 if (autoGeneratedKeys != Statement.RETURN_GENERATED_KEYS && |
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
|
861 autoGeneratedKeys != Statement.NO_GENERATED_KEYS) |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
862 throw new SQLException("Invalid argument, expected RETURN_GENERATED_KEYS or NO_GENERATED_KEYS", "M1M05"); |
77
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
863 |
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
|
864 /* MonetDB has no way to disable this, so just do the normal thing ;) */ |
292
b127164342c4
Introduce default general behavior settings DEF_... for MonetResultSets and use them
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
288
diff
changeset
|
865 return prepareStatement(sql, MonetResultSet.DEF_RESULTSETTYPE, MonetResultSet.DEF_CONCURRENCY, MonetResultSet.DEF_HOLDABILITY); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
866 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
867 |
77
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
868 /** |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
869 * Creates a default PreparedStatement object capable of returning the auto-generated keys designated by the given array. |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
870 * This array contains the indexes of the columns in the target table that contain the auto-generated keys that should be made available. |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
871 * The driver will ignore the array if the SQL statement is not an INSERT statement, or an SQL statement able to |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
872 * return auto-generated keys (the list of such statements is vendor-specific). |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
873 * |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
874 * An SQL statement with or without IN parameters can be pre-compiled and stored in a PreparedStatement object. |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
875 * This object can then be used to efficiently execute this statement multiple times. |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
876 * |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
877 * Note: This method is optimized for handling parametric SQL statements that benefit from precompilation. |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
878 * If the driver supports precompilation, the method prepareStatement will send the statement to the database for precompilation. |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
879 * Some drivers may not support precompilation. In this case, the statement may not be sent to the database until the PreparedStatement |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
880 * object is executed. This has no direct effect on users; however, it does affect which methods throw certain SQLExceptions. |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
881 * |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
882 * Result sets created using the returned PreparedStatement object will by default be type TYPE_FORWARD_ONLY and have |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
883 * a concurrency level of CONCUR_READ_ONLY. The holdability of the created result sets can be determined by calling getHoldability(). |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
884 * |
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
|
885 * @param sql - an SQL statement that may contain one or more '?' IN parameter placeholders |
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
|
886 * @param columnIndexes - an array of column indexes indicating the columns that should be returned from the inserted row or rows |
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
|
887 * @return a new PreparedStatement object, containing the pre-compiled statement, that is capable of |
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
|
888 * returning the auto-generated keys designated by the given array of column indexes |
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
|
889 * @throws SQLException - if a database access error occurs or this method is called on a closed connection |
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
|
890 * @throws SQLFeatureNotSupportedException - if the JDBC driver does not support this method |
77
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
891 */ |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
892 @Override |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
893 public PreparedStatement prepareStatement(final String sql, final int[] columnIndexes) throws SQLException { |
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
|
894 throw newSQLFeatureNotSupportedException("prepareStatement(String sql, int[] columnIndexes)"); |
77
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
895 } |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
896 |
77
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
897 /** |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
898 * Creates a default PreparedStatement object capable of returning the auto-generated keys designated by the given array. |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
899 * This array contains the names of the columns in the target table that contain the auto-generated keys that should be returned. |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
900 * The driver will ignore the array if the SQL statement is not an INSERT statement, or an SQL statement able to |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
901 * return auto-generated keys (the list of such statements is vendor-specific). |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
902 * |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
903 * An SQL statement with or without IN parameters can be pre-compiled and stored in a PreparedStatement object. |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
904 * This object can then be used to efficiently execute this statement multiple times. |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
905 * |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
906 * Note: This method is optimized for handling parametric SQL statements that benefit from precompilation. |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
907 * If the driver supports precompilation, the method prepareStatement will send the statement to the database for precompilation. |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
908 * Some drivers may not support precompilation. In this case, the statement may not be sent to the database until the PreparedStatement |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
909 * object is executed. This has no direct effect on users; however, it does affect which methods throw certain SQLExceptions. |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
910 * |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
911 * Result sets created using the returned PreparedStatement object will by default be type TYPE_FORWARD_ONLY and have |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
912 * a concurrency level of CONCUR_READ_ONLY. The holdability of the created result sets can be determined by calling getHoldability(). |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
913 * |
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
|
914 * @param sql - an SQL statement that may contain one or more '?' IN parameter placeholders |
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
|
915 * @param columnNames - an array of column names indicating the columns that should be returned from the inserted row or rows |
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
|
916 * @return a new PreparedStatement object, containing the pre-compiled statement, that is capable of |
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
|
917 * returning the auto-generated keys designated by the given array of column names |
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
|
918 * @throws SQLException - if a database access error occurs or this method is called on a closed connection |
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
|
919 * @throws SQLFeatureNotSupportedException - if the JDBC driver does not support this method |
77
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
920 */ |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
921 @Override |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
922 public PreparedStatement prepareStatement(final String sql, final String[] columnNames) throws SQLException { |
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
|
923 throw newSQLFeatureNotSupportedException("prepareStatement(String sql, String[] columnNames)"); |
77
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
924 } |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
925 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
926 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
927 * Removes the given Savepoint object from the current transaction. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
928 * Any reference to the savepoint after it have been removed will |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
929 * cause an SQLException to be thrown. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
930 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
931 * @param savepoint the Savepoint object to be removed |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
932 * @throws SQLException if a database access error occurs or the given |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
933 * Savepoint object is not a valid savepoint in the current |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
934 * transaction |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
935 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
936 @Override |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
937 public void releaseSavepoint(final Savepoint savepoint) throws SQLException { |
348
bcb9a99d399d
Add private checkNotClosed() method to check if the connection is not closed.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
345
diff
changeset
|
938 checkNotClosed(); |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
939 if (!(savepoint instanceof MonetSavepoint)) |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
940 throw new SQLException("This driver can only handle savepoints it created itself", "M0M06"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
941 |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
942 final MonetSavepoint sp = (MonetSavepoint)savepoint; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
943 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
944 // note: can't use sendIndependentCommand here because we need |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
945 // to process the auto_commit state the server gives |
77
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
946 sendTransactionCommand("RELEASE SAVEPOINT " + sp.getName()); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
947 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
948 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
949 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
950 * Undoes all changes made in the current transaction and releases |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
951 * any database locks currently held by this Connection object. |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
952 * This method should be used only when auto-commit mode has been disabled. |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
953 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
954 * @throws SQLException if a database access error occurs or this |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
955 * Connection object is in auto-commit mode |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
956 * @see #setAutoCommit(boolean) |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
957 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
958 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
959 public void rollback() throws SQLException { |
348
bcb9a99d399d
Add private checkNotClosed() method to check if the connection is not closed.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
345
diff
changeset
|
960 checkNotClosed(); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
961 // note: can't use sendIndependentCommand here because we need |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
962 // to process the auto_commit state the server gives |
77
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
963 sendTransactionCommand("ROLLBACK"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
964 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
965 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
966 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
967 * Undoes all changes made after the given Savepoint object was set. |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
968 * |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
969 * This method should be used only when auto-commit has been disabled. |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
970 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
971 * @param savepoint the Savepoint object to roll back to |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
972 * @throws SQLException if a database access error occurs, the |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
973 * Savepoint object is no longer valid, or this Connection |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
974 * object is currently in auto-commit mode |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
975 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
976 @Override |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
977 public void rollback(final Savepoint savepoint) throws SQLException { |
348
bcb9a99d399d
Add private checkNotClosed() method to check if the connection is not closed.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
345
diff
changeset
|
978 checkNotClosed(); |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
979 if (!(savepoint instanceof MonetSavepoint)) |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
980 throw new SQLException("This driver can only handle savepoints it created itself", "M0M06"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
981 |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
982 final MonetSavepoint sp = (MonetSavepoint)savepoint; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
983 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
984 // note: can't use sendIndependentCommand here because we need |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
985 // to process the auto_commit state the server gives |
77
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
986 sendTransactionCommand("ROLLBACK TO SAVEPOINT " + sp.getName()); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
987 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
988 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
989 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
990 * Sets this connection's auto-commit mode to the given state. If a |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
991 * connection is in auto-commit mode, then all its SQL statements |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
992 * will be executed and committed as individual transactions. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
993 * Otherwise, its SQL statements are grouped into transactions that |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
994 * are terminated by a call to either the method commit or the |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
995 * method rollback. By default, new connections are in auto-commit mode. |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
996 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
997 * The commit occurs when the statement completes or the next |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
998 * execute occurs, whichever comes first. In the case of statements |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
999 * returning a ResultSet object, the statement completes when the |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1000 * last row of the ResultSet object has been retrieved or the |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1001 * ResultSet object has been closed. In advanced cases, a single |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1002 * statement may return multiple results as well as output parameter |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1003 * values. In these cases, the commit occurs when all results and |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1004 * output parameter values have been retrieved. |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1005 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1006 * NOTE: If this method is called during a transaction, the |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1007 * transaction is committed. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1008 * |
8
a27ee2cb14a0
Replace String methods equals("") and "".equals( with isEmpty()
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
0
diff
changeset
|
1009 * @param autoCommit true to enable auto-commit mode; false to disable it |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1010 * @throws SQLException if a database access error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1011 * @see #getAutoCommit() |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1012 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1013 @Override |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
1014 public void setAutoCommit(final boolean autoCommit) throws SQLException { |
348
bcb9a99d399d
Add private checkNotClosed() method to check if the connection is not closed.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
345
diff
changeset
|
1015 checkNotClosed(); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1016 if (this.autoCommit != autoCommit) { |
407
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
1017 sendControlCommand(autoCommit ? "auto_commit 1" : "auto_commit 0"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1018 this.autoCommit = autoCommit; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1019 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1020 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1021 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1022 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1023 * Sets the given catalog name in order to select a subspace of this |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1024 * Connection object's database in which to work. If the driver |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1025 * does not support catalogs, it will silently ignore this request. |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1026 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1027 @Override |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
1028 public void setCatalog(final String catalog) { |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1029 // silently ignore this request as MonetDB does not support catalogs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1030 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1031 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1032 /** |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1033 * Changes the default holdability of ResultSet objects created using this |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1034 * Connection object to the given holdability. The default holdability of |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1035 * ResultSet objects can be be determined by invoking DatabaseMetaData.getResultSetHoldability(). |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1036 * |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1037 * @param holdability - a ResultSet holdability constant; one of |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1038 * ResultSet.HOLD_CURSORS_OVER_COMMIT or |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1039 * ResultSet.CLOSE_CURSORS_AT_COMMIT |
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
|
1040 * @throws SQLException - if a database access error occurs or this method is called on a closed connection |
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
|
1041 * @throws SQLFeatureNotSupportedException - if the JDBC driver does not support this method or argument |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1042 * @see #getHoldability() |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1043 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1044 @Override |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
1045 public void setHoldability(final int holdability) throws SQLException { |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1046 // we only support ResultSet.HOLD_CURSORS_OVER_COMMIT |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1047 if (holdability != ResultSet.HOLD_CURSORS_OVER_COMMIT) |
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
|
1048 throw newSQLFeatureNotSupportedException("setHoldability(CLOSE_CURSORS_AT_COMMIT)"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1049 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1050 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1051 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1052 * Puts this connection in read-only mode as a hint to the driver to |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1053 * enable database optimizations. MonetDB doesn't support any mode |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1054 * here, hence an SQLWarning is generated if attempted to set |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1055 * to true here. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1056 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1057 * @param readOnly true enables read-only mode; false disables it |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1058 * @throws SQLException if a database access error occurs or this |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1059 * method is called during a transaction. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1060 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1061 @Override |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
1062 public void setReadOnly(final boolean readOnly) throws SQLException { |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1063 if (readOnly == true) |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1064 addWarning("cannot setReadOnly(true): read-only Connection mode not supported", "01M08"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1065 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1066 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1067 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1068 * Creates an unnamed savepoint in the current transaction and |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1069 * returns the new Savepoint object that represents it. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1070 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1071 * @return the new Savepoint object |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1072 * @throws SQLException if a database access error occurs or this Connection |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1073 * object is currently in auto-commit mode |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1074 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1075 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1076 public Savepoint setSavepoint() throws SQLException { |
407
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
1077 return setSavepoint(null); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1078 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1079 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1080 /** |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1081 * Creates a savepoint with the given name in the current transaction |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1082 * and returns the new Savepoint object that represents it. |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1083 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1084 * @param name a String containing the name of the savepoint |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1085 * @return the new Savepoint object |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1086 * @throws SQLException if a database access error occurs or this Connection |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1087 * object is currently in auto-commit mode |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1088 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1089 @Override |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
1090 public Savepoint setSavepoint(final String name) throws SQLException { |
348
bcb9a99d399d
Add private checkNotClosed() method to check if the connection is not closed.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
345
diff
changeset
|
1091 checkNotClosed(); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1092 // create a new Savepoint object |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
1093 final MonetSavepoint sp; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1094 try { |
407
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
1095 sp = (name != null) ? new MonetSavepoint(name) : new MonetSavepoint(); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1096 } catch (IllegalArgumentException e) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1097 throw new SQLException(e.getMessage(), "M0M03"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1098 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1099 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1100 // note: can't use sendIndependentCommand here because we need |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1101 // to process the auto_commit state the server gives |
77
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
1102 sendTransactionCommand("SAVEPOINT " + sp.getName()); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1103 return sp; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1104 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1105 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1106 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1107 * Attempts to change the transaction isolation level for this |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1108 * Connection object to the one given. The constants defined in the |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1109 * interface Connection are the possible transaction isolation levels. |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1110 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1111 * @param level one of the following Connection constants: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1112 * Connection.TRANSACTION_READ_UNCOMMITTED, |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1113 * Connection.TRANSACTION_READ_COMMITTED, |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1114 * Connection.TRANSACTION_REPEATABLE_READ, or |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1115 * Connection.TRANSACTION_SERIALIZABLE. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1116 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1117 @Override |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
1118 public void setTransactionIsolation(final int level) { |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1119 if (level != TRANSACTION_SERIALIZABLE) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1120 addWarning("MonetDB only supports fully serializable " + |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1121 "transactions, continuing with transaction level " + |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1122 "raised to TRANSACTION_SERIALIZABLE", "01M09"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1123 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1124 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1125 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1126 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1127 * Installs the given TypeMap object as the type map for this |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1128 * Connection object. The type map will be used for the custom |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1129 * mapping of SQL structured types and distinct types. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1130 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1131 * @param map the java.util.Map object to install as the replacement for |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1132 * this Connection object's default type map |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1133 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1134 @Override |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
1135 public void setTypeMap(final Map<String, Class<?>> map) { |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1136 typeMap = map; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1137 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1138 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1139 /** |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1140 * Returns a string identifying this Connection to the MonetDB server. |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1141 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1142 * @return a String representing this Object |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1143 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1144 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1145 public String toString() { |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1146 return "MonetDB Connection (" + getJDBCURL() + ") " + |
243
337a1292fe18
Fixed MonetConnection string description.
Pedro Ferreira <pedro.ferreira@monetdbsolutions.com>
parents:
225
diff
changeset
|
1147 (closed ? "disconnected" : "connected"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1148 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1149 |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1150 //== Java 1.6 methods (JDBC 4.0) |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1151 |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1152 /** |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1153 * Factory method for creating Array objects. |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1154 * |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1155 * Note: When createArrayOf is used to create an array object that |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1156 * maps to a primitive data type, then it is implementation-defined |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1157 * whether the Array object is an array of that primitive data type |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1158 * or an array of Object. |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1159 * |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1160 * Note: The JDBC driver is responsible for mapping the elements |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1161 * Object array to the default JDBC SQL type defined in |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1162 * java.sql.Types for the given class of Object. The default mapping |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1163 * is specified in Appendix B of the JDBC specification. If the |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1164 * resulting JDBC type is not the appropriate type for the given |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1165 * typeName then it is implementation defined whether an |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1166 * SQLException is thrown or the driver supports the resulting conversion. |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1167 * |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1168 * @param typeName the SQL name of the type the elements of the |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1169 * array map to. The typeName is a database-specific name |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1170 * which may be the name of a built-in type, a user-defined |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1171 * type or a standard SQL type supported by this database. |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1172 * This is the value returned by Array.getBaseTypeName |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1173 * @return an Array object whose elements map to the specified SQL type |
89
a6608e9581c1
Moved content of ChangeLog to ChangeLog-Archive.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
77
diff
changeset
|
1174 * @throws SQLException - if a database error occurs, the JDBC type is not appropriate for the typeName and |
a6608e9581c1
Moved content of ChangeLog to ChangeLog-Archive.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
77
diff
changeset
|
1175 * the conversion is not supported, the typeName is null or this method is called on a closed connection |
a6608e9581c1
Moved content of ChangeLog to ChangeLog-Archive.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
77
diff
changeset
|
1176 * @throws SQLFeatureNotSupportedException - if the JDBC driver does not support this data type |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1177 * @since 1.6 |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1178 */ |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1179 @Override |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
1180 public java.sql.Array createArrayOf(final String typeName, final Object[] elements) throws SQLException { |
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
|
1181 throw newSQLFeatureNotSupportedException("createArrayOf"); |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1182 } |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1183 |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1184 |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1185 /** |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1186 * Constructs an object that implements the Clob interface. The |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1187 * object returned initially contains no data. The setAsciiStream, |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1188 * setCharacterStream and setString methods of the Clob interface |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1189 * may be used to add data to the Clob. |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1190 * |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1191 * @return a MonetClob instance |
89
a6608e9581c1
Moved content of ChangeLog to ChangeLog-Archive.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
77
diff
changeset
|
1192 * @throws SQLException - if an object that implements the Clob interface can not be constructed, |
a6608e9581c1
Moved content of ChangeLog to ChangeLog-Archive.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
77
diff
changeset
|
1193 * this method is called on a closed connection or a database access error occurs. |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1194 * @since 1.6 |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1195 */ |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1196 @Override |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1197 public java.sql.Clob createClob() throws SQLException { |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1198 return new MonetClob(""); |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1199 } |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1200 |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1201 /** |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1202 * Constructs an object that implements the Blob interface. The |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1203 * object returned initially contains no data. The setBinaryStream |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1204 * and setBytes methods of the Blob interface may be used to add |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1205 * data to the Blob. |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1206 * |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1207 * @return a MonetBlob instance |
89
a6608e9581c1
Moved content of ChangeLog to ChangeLog-Archive.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
77
diff
changeset
|
1208 * @throws SQLException - if an object that implements the Blob interface can not be constructed, |
a6608e9581c1
Moved content of ChangeLog to ChangeLog-Archive.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
77
diff
changeset
|
1209 * this method is called on a closed connection or a database access error occurs. |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1210 * @since 1.6 |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1211 */ |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1212 @Override |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1213 public java.sql.Blob createBlob() throws SQLException { |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
1214 return new MonetBlob(new byte[1]); |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1215 } |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1216 |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1217 /** |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1218 * Constructs an object that implements the NClob interface. The |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1219 * object returned initially contains no data. The setAsciiStream, |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1220 * setCharacterStream and setString methods of the NClob interface |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1221 * may be used to add data to the NClob. |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1222 * |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1223 * @return an NClob instance |
89
a6608e9581c1
Moved content of ChangeLog to ChangeLog-Archive.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
77
diff
changeset
|
1224 * @throws SQLException - if an object that implements the NClob interface can not be constructed, |
a6608e9581c1
Moved content of ChangeLog to ChangeLog-Archive.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
77
diff
changeset
|
1225 * this method is called on a closed connection or a database access error occurs. |
a6608e9581c1
Moved content of ChangeLog to ChangeLog-Archive.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
77
diff
changeset
|
1226 * @throws SQLFeatureNotSupportedException - if the JDBC driver does not support this data type |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1227 * @since 1.6 |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1228 */ |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1229 @Override |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1230 public java.sql.NClob createNClob() throws SQLException { |
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
|
1231 throw newSQLFeatureNotSupportedException("createNClob"); |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1232 } |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1233 |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1234 /** |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1235 * Factory method for creating Struct objects. |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1236 * |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1237 * @param typeName the SQL type name of the SQL structured type that |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1238 * this Struct object maps to. The typeName is the name of a |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1239 * user-defined type that has been defined for this database. |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1240 * It is the value returned by Struct.getSQLTypeName. |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1241 * @param attributes the attributes that populate the returned object |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1242 * @return a Struct object that maps to the given SQL type and is |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1243 * populated with the given attributes |
89
a6608e9581c1
Moved content of ChangeLog to ChangeLog-Archive.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
77
diff
changeset
|
1244 * @throws SQLException - if an object that implements the Struct interface can not be constructed, |
a6608e9581c1
Moved content of ChangeLog to ChangeLog-Archive.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
77
diff
changeset
|
1245 * this method is called on a closed connection or a database access error occurs. |
a6608e9581c1
Moved content of ChangeLog to ChangeLog-Archive.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
77
diff
changeset
|
1246 * @throws SQLFeatureNotSupportedException - if the JDBC driver does not support this data type |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1247 * @since 1.6 |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1248 */ |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1249 @Override |
77
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
1250 public java.sql.Struct createStruct(String typeName, Object[] attributes) throws SQLException { |
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
|
1251 throw newSQLFeatureNotSupportedException("createStruct"); |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1252 } |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1253 |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1254 /** |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1255 * Constructs an object that implements the SQLXML interface. The |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1256 * object returned initially contains no data. The |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1257 * createXmlStreamWriter object and setString method of the SQLXML |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1258 * interface may be used to add data to the SQLXML object. |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1259 * |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1260 * @return An object that implements the SQLXML interface |
89
a6608e9581c1
Moved content of ChangeLog to ChangeLog-Archive.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
77
diff
changeset
|
1261 * @throws SQLException - if an object that implements the SQLXML interface can not be constructed, |
a6608e9581c1
Moved content of ChangeLog to ChangeLog-Archive.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
77
diff
changeset
|
1262 * this method is called on a closed connection or a database access error occurs. |
a6608e9581c1
Moved content of ChangeLog to ChangeLog-Archive.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
77
diff
changeset
|
1263 * @throws SQLFeatureNotSupportedException - if the JDBC driver does not support this data type |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1264 * @since 1.6 |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1265 */ |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1266 @Override |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1267 public java.sql.SQLXML createSQLXML() throws SQLException { |
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
|
1268 throw newSQLFeatureNotSupportedException("createSQLXML"); |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1269 } |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1270 |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1271 /** |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1272 * Returns true if the connection has not been closed and is still |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1273 * valid. The driver shall submit a query on the connection or use |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1274 * some other mechanism that positively verifies the connection is |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1275 * still valid when this method is called. |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1276 * |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1277 * The query submitted by the driver to validate the connection |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1278 * shall be executed in the context of the current transaction. |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1279 * |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1280 * @param timeout The time in seconds to wait for the database |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1281 * operation used to validate the connection to complete. If |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1282 * the timeout period expires before the operation completes, |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1283 * this method returns false. A value of 0 indicates a |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1284 * timeout is not applied to the database operation. |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1285 * @return true if the connection is valid, false otherwise |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1286 * @throws SQLException if the value supplied for timeout is less than 0 |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1287 * @since 1.6 |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1288 */ |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1289 @Override |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
1290 public boolean isValid(final int timeout) throws SQLException { |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1291 if (timeout < 0) |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1292 throw new SQLException("timeout is less than 0", "M1M05"); |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1293 if (closed) |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1294 return false; |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1295 |
284
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
1296 // ping monetdb server using query: select 1; |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1297 Statement stmt = null; |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1298 ResultSet rs = null; |
167
89e954e7acbb
Correct implementation of method Connection.isValid().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
164
diff
changeset
|
1299 boolean isValid = false; |
345
45155894aece
Remove catch code from finally part where original timeout is reset on server.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
343
diff
changeset
|
1300 final int original_timeout = this.lastSetQueryTimeout; |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1301 try { |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1302 stmt = createStatement(); |
167
89e954e7acbb
Correct implementation of method Connection.isValid().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
164
diff
changeset
|
1303 if (stmt != null) { |
89e954e7acbb
Correct implementation of method Connection.isValid().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
164
diff
changeset
|
1304 if (timeout > 0 && original_timeout != timeout) { |
89e954e7acbb
Correct implementation of method Connection.isValid().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
164
diff
changeset
|
1305 // we need to change the requested timeout for this test query |
89e954e7acbb
Correct implementation of method Connection.isValid().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
164
diff
changeset
|
1306 stmt.setQueryTimeout(timeout); |
89e954e7acbb
Correct implementation of method Connection.isValid().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
164
diff
changeset
|
1307 } |
89e954e7acbb
Correct implementation of method Connection.isValid().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
164
diff
changeset
|
1308 rs = stmt.executeQuery("SELECT 1"); |
89e954e7acbb
Correct implementation of method Connection.isValid().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
164
diff
changeset
|
1309 if (rs != null && rs.next()) { |
89e954e7acbb
Correct implementation of method Connection.isValid().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
164
diff
changeset
|
1310 isValid = true; |
89e954e7acbb
Correct implementation of method Connection.isValid().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
164
diff
changeset
|
1311 } |
89e954e7acbb
Correct implementation of method Connection.isValid().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
164
diff
changeset
|
1312 } |
89e954e7acbb
Correct implementation of method Connection.isValid().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
164
diff
changeset
|
1313 } catch (SQLException se) { |
89e954e7acbb
Correct implementation of method Connection.isValid().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
164
diff
changeset
|
1314 String msg = se.getMessage(); |
175
8700d9ef2ace
Added possibility via a connection property to let the JDBC driver
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
167
diff
changeset
|
1315 // System.out.println(se.getSQLState() + " Con.isValid(): " + msg); |
8700d9ef2ace
Added possibility via a connection property to let the JDBC driver
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
167
diff
changeset
|
1316 if (msg != null && msg.equalsIgnoreCase("Current transaction is aborted (please ROLLBACK)")) { |
8700d9ef2ace
Added possibility via a connection property to let the JDBC driver
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
167
diff
changeset
|
1317 // Must use equalsIgnoreCase() here because up to Jul2017 release 'Current' was 'current' so with lowercase c. |
8700d9ef2ace
Added possibility via a connection property to let the JDBC driver
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
167
diff
changeset
|
1318 // It changed to 'Current' after Jul2017 release. We need to support all server versions. |
8700d9ef2ace
Added possibility via a connection property to let the JDBC driver
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
167
diff
changeset
|
1319 // SQLState = 25005 |
167
89e954e7acbb
Correct implementation of method Connection.isValid().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
164
diff
changeset
|
1320 isValid = true; |
89e954e7acbb
Correct implementation of method Connection.isValid().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
164
diff
changeset
|
1321 } |
89e954e7acbb
Correct implementation of method Connection.isValid().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
164
diff
changeset
|
1322 /* ignore stmt errors/exceptions, we are only testing if the connection is still alive and usable */ |
89e954e7acbb
Correct implementation of method Connection.isValid().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
164
diff
changeset
|
1323 } finally { |
345
45155894aece
Remove catch code from finally part where original timeout is reset on server.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
343
diff
changeset
|
1324 /* when changed, reset the original server timeout value on the server */ |
45155894aece
Remove catch code from finally part where original timeout is reset on server.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
343
diff
changeset
|
1325 if (timeout > 0 && original_timeout != this.lastSetQueryTimeout) { |
45155894aece
Remove catch code from finally part where original timeout is reset on server.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
343
diff
changeset
|
1326 this.lastSetQueryTimeout = original_timeout; |
343
48ee2ca98975
Added test and fix for bug 6782, ie set the connection's query timeout explicitly at the end of isValid method.
Pedro Ferreira <pedro.ferreira@monetdbsolutions.com>
parents:
336
diff
changeset
|
1327 Statement stmt2 = null; |
48ee2ca98975
Added test and fix for bug 6782, ie set the connection's query timeout explicitly at the end of isValid method.
Pedro Ferreira <pedro.ferreira@monetdbsolutions.com>
parents:
336
diff
changeset
|
1328 try { |
48ee2ca98975
Added test and fix for bug 6782, ie set the connection's query timeout explicitly at the end of isValid method.
Pedro Ferreira <pedro.ferreira@monetdbsolutions.com>
parents:
336
diff
changeset
|
1329 /* we have to set in the server explicitly, because the test 'queryTimeout != connection.lastSetQueryTimeout' |
345
45155894aece
Remove catch code from finally part where original timeout is reset on server.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
343
diff
changeset
|
1330 on MonetStatement.internalExecute(sql) won't pass and the server won't be set back */ |
343
48ee2ca98975
Added test and fix for bug 6782, ie set the connection's query timeout explicitly at the end of isValid method.
Pedro Ferreira <pedro.ferreira@monetdbsolutions.com>
parents:
336
diff
changeset
|
1331 stmt2 = this.createStatement(); |
48ee2ca98975
Added test and fix for bug 6782, ie set the connection's query timeout explicitly at the end of isValid method.
Pedro Ferreira <pedro.ferreira@monetdbsolutions.com>
parents:
336
diff
changeset
|
1332 stmt2.execute("CALL \"sys\".\"settimeout\"(" + this.lastSetQueryTimeout + ")"); |
48ee2ca98975
Added test and fix for bug 6782, ie set the connection's query timeout explicitly at the end of isValid method.
Pedro Ferreira <pedro.ferreira@monetdbsolutions.com>
parents:
336
diff
changeset
|
1333 } catch (SQLException se) { |
345
45155894aece
Remove catch code from finally part where original timeout is reset on server.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
343
diff
changeset
|
1334 /* ignore stmt errors/exceptions, we are only testing if the connection is still alive and usable */ |
343
48ee2ca98975
Added test and fix for bug 6782, ie set the connection's query timeout explicitly at the end of isValid method.
Pedro Ferreira <pedro.ferreira@monetdbsolutions.com>
parents:
336
diff
changeset
|
1335 } finally { |
48ee2ca98975
Added test and fix for bug 6782, ie set the connection's query timeout explicitly at the end of isValid method.
Pedro Ferreira <pedro.ferreira@monetdbsolutions.com>
parents:
336
diff
changeset
|
1336 closeResultsetStatement(null, stmt2); |
48ee2ca98975
Added test and fix for bug 6782, ie set the connection's query timeout explicitly at the end of isValid method.
Pedro Ferreira <pedro.ferreira@monetdbsolutions.com>
parents:
336
diff
changeset
|
1337 } |
48ee2ca98975
Added test and fix for bug 6782, ie set the connection's query timeout explicitly at the end of isValid method.
Pedro Ferreira <pedro.ferreira@monetdbsolutions.com>
parents:
336
diff
changeset
|
1338 } |
300
8cc3b51d1984
Add a utility method to close objects ignoring any possible SQLExceptions thrown.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
296
diff
changeset
|
1339 closeResultsetStatement(rs, stmt); |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1340 } |
167
89e954e7acbb
Correct implementation of method Connection.isValid().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
164
diff
changeset
|
1341 return isValid; |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1342 } |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1343 |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1344 /** |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1345 * Returns the value of the client info property specified by name. |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1346 * This method may return null if the specified client info property |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1347 * has not been set and does not have a default value. |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1348 * This method will also return null if the specified client info |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1349 * property name is not supported by the driver. |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1350 * Applications may use the DatabaseMetaData.getClientInfoProperties method |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1351 * to determine the client info properties supported by the driver. |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1352 * |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1353 * @param name - The name of the client info property to retrieve |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1354 * @return The value of the client info property specified or null |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1355 * @throws SQLException - if the database server returns an error |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1356 * when fetching the client info value from the database |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1357 * or this method is called on a closed connection |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1358 * @since 1.6 |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1359 */ |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1360 @Override |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
1361 public String getClientInfo(final String name) throws SQLException { |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1362 if (name == null || name.isEmpty()) |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1363 return null; |
348
bcb9a99d399d
Add private checkNotClosed() method to check if the connection is not closed.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
345
diff
changeset
|
1364 checkNotClosed(); |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1365 return conn_props.getProperty(name); |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1366 } |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1367 |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1368 /** |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1369 * Returns a list containing the name and current value of each client info |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1370 * property supported by the driver. The value of a client info property may |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1371 * be null if the property has not been set and does not have a default value. |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1372 * |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1373 * @return A Properties object that contains the name and current value |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1374 * of each of the client info properties supported by the driver. |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1375 * @throws SQLException - if the database server returns an error |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1376 * when fetching the client info value from the database |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1377 * or this method is called on a closed connection |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1378 * @since 1.6 |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1379 */ |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1380 @Override |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1381 public Properties getClientInfo() throws SQLException { |
348
bcb9a99d399d
Add private checkNotClosed() method to check if the connection is not closed.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
345
diff
changeset
|
1382 checkNotClosed(); |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1383 // return a clone of the connection properties object |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1384 return new Properties(conn_props); |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1385 } |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1386 |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1387 /** |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1388 * Sets the value of the client info property specified by name to the value specified by value. |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1389 * Applications may use the DatabaseMetaData.getClientInfoProperties method to determine |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1390 * the client info properties supported by the driver and the maximum length that may be specified |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1391 * for each property. |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1392 * |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1393 * The driver stores the value specified in a suitable location in the database. For example |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1394 * in a special register, session parameter, or system table column. For efficiency the driver |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1395 * may defer setting the value in the database until the next time a statement is executed |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1396 * or prepared. Other than storing the client information in the appropriate place in the |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1397 * database, these methods shall not alter the behavior of the connection in anyway. |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1398 * The values supplied to these methods are used for accounting, diagnostics and debugging purposes only. |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1399 * |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1400 * The driver shall generate a warning if the client info name specified is not recognized by the driver. |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1401 * |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1402 * If the value specified to this method is greater than the maximum length for the property |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1403 * the driver may either truncate the value and generate a warning or generate a SQLClientInfoException. |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1404 * If the driver generates a SQLClientInfoException, the value specified was not set on the connection. |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1405 * |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1406 * The following are standard client info properties. Drivers are not required to support these |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1407 * properties however if the driver supports a client info property that can be described by one |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1408 * of the standard properties, the standard property name should be used. |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1409 * |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1410 * ApplicationName - The name of the application currently utilizing the connection |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1411 * ClientUser - The name of the user that the application using the connection is performing work for. |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1412 * This may not be the same as the user name that was used in establishing the connection. |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1413 * ClientHostname - The hostname of the computer the application using the connection is running on. |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1414 * |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1415 * @param name - The name of the client info property to set |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1416 * @param value - The value to set the client info property to. If the |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1417 * value is null, the current value of the specified property is cleared. |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1418 * @throws SQLClientInfoException - if the database server returns an error |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1419 * while setting the clientInfo values on the database server |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1420 * or this method is called on a closed connection |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1421 * @since 1.6 |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1422 */ |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1423 @Override |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
1424 public void setClientInfo(final String name, final String value) throws SQLClientInfoException { |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1425 if (name == null || name.isEmpty()) { |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1426 addWarning("setClientInfo: missing property name", "01M07"); |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1427 return; |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1428 } |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1429 // If the value is null, the current value of the specified property is cleared. |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1430 if (value == null) { |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1431 if (conn_props.containsKey(name)) |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1432 conn_props.remove(name); |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1433 return; |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1434 } |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1435 // only set value for supported property names |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1436 if (name.equals("host") || |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1437 name.equals("port") || |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1438 name.equals("user") || |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1439 name.equals("password") || |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1440 name.equals("database") || |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1441 name.equals("language") || |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1442 name.equals("so_timeout") || |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1443 name.equals("debug") || |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1444 name.equals("hash") || |
175
8700d9ef2ace
Added possibility via a connection property to let the JDBC driver
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
167
diff
changeset
|
1445 name.equals("treat_blob_as_binary") || |
8700d9ef2ace
Added possibility via a connection property to let the JDBC driver
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
167
diff
changeset
|
1446 name.equals("treat_clob_as_varchar")) |
8700d9ef2ace
Added possibility via a connection property to let the JDBC driver
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
167
diff
changeset
|
1447 { |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1448 conn_props.setProperty(name, value); |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1449 } else { |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1450 addWarning("setClientInfo: " + name + "is not a recognised property", "01M07"); |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1451 } |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1452 } |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1453 |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1454 /** |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1455 * Sets the value of the connection's client info properties. |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1456 * The Properties object contains the names and values of the client info |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1457 * properties to be set. The set of client info properties contained in the |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1458 * properties list replaces the current set of client info properties on the connection. |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1459 * If a property that is currently set on the connection is not present in the |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1460 * properties list, that property is cleared. Specifying an empty properties list |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1461 * will clear all of the properties on the connection. |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1462 * See setClientInfo (String, String) for more information. |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1463 * |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1464 * If an error occurs in setting any of the client info properties, a |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1465 * SQLClientInfoException is thrown. The SQLClientInfoException contains information |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1466 * indicating which client info properties were not set. The state of the client |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1467 * information is unknown because some databases do not allow multiple client info |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1468 * properties to be set atomically. For those databases, one or more properties may |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1469 * have been set before the error occurred. |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1470 * |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1471 * @param props - The list of client info properties to set |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1472 * @throws SQLClientInfoException - if the database server returns an error |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1473 * while setting the clientInfo values on the database server |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1474 * or this method is called on a closed connection |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1475 * @since 1.6 |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1476 */ |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1477 @Override |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
1478 public void setClientInfo(final Properties props) throws SQLClientInfoException { |
47
562dbfb2fee8
Prevent null pointer exception by checking props argument
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
45
diff
changeset
|
1479 if (props != null) { |
562dbfb2fee8
Prevent null pointer exception by checking props argument
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
45
diff
changeset
|
1480 for (Entry<Object, Object> entry : props.entrySet()) { |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
1481 setClientInfo(entry.getKey().toString(), entry.getValue().toString()); |
47
562dbfb2fee8
Prevent null pointer exception by checking props argument
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
45
diff
changeset
|
1482 } |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1483 } |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1484 } |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1485 |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1486 |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1487 //== Java 1.7 methods (JDBC 4.1) |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1488 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1489 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1490 * Sets the given schema name to access. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1491 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1492 * @param schema the name of a schema in which to work |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1493 * @throws SQLException if a database access error occurs or this |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1494 * method is called on a closed connection |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1495 * @since 1.7 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1496 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1497 @Override |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
1498 public void setSchema(final String schema) throws SQLException { |
348
bcb9a99d399d
Add private checkNotClosed() method to check if the connection is not closed.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
345
diff
changeset
|
1499 checkNotClosed(); |
284
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
1500 if (schema == null || schema.isEmpty()) |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1501 throw new SQLException("Missing schema name", "M1M05"); |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1502 |
284
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
1503 Statement st = null; |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1504 try { |
284
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
1505 st = createStatement(); |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
1506 if (st != null) |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
1507 st.execute("SET SCHEMA \"" + schema + "\""); |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
1508 // do not catch any Exception, just let it propagate |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1509 } finally { |
300
8cc3b51d1984
Add a utility method to close objects ignoring any possible SQLExceptions thrown.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
296
diff
changeset
|
1510 closeResultsetStatement(null, st); |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1511 } |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1512 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1513 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1514 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1515 * Retrieves this Connection object's current schema name. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1516 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1517 * @return the current schema name or null if there is none |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1518 * @throws SQLException if a database access error occurs or this |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1519 * method is called on a closed connection |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1520 * @since 1.7 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1521 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1522 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1523 public String getSchema() throws SQLException { |
348
bcb9a99d399d
Add private checkNotClosed() method to check if the connection is not closed.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
345
diff
changeset
|
1524 checkNotClosed(); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1525 |
284
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
1526 String cur_schema = null; |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
1527 Statement st = null; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1528 ResultSet rs = null; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1529 try { |
284
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
1530 st = createStatement(); |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
1531 if (st != null) { |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
1532 rs = st.executeQuery("SELECT CURRENT_SCHEMA"); |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
1533 if (rs != null) { |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
1534 if (rs.next()) |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
1535 cur_schema = rs.getString(1); |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
1536 } |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
1537 } |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
1538 // do not catch any Exception, just let it propagate |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1539 } finally { |
300
8cc3b51d1984
Add a utility method to close objects ignoring any possible SQLExceptions thrown.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
296
diff
changeset
|
1540 closeResultsetStatement(rs, st); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1541 } |
284
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
1542 if (cur_schema == null) |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
1543 throw new SQLException("Failed to fetch schema name", "02000"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1544 return cur_schema; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1545 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1546 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1547 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1548 * Terminates an open connection. Calling abort results in: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1549 * * The connection marked as closed |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1550 * * Closes any physical connection to the database |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1551 * * Releases resources used by the connection |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1552 * * Insures that any thread that is currently accessing the |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1553 * connection will either progress to completion or throw an |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1554 * SQLException. |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1555 * Calling abort marks the connection closed and releases any |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1556 * resources. Calling abort on a closed connection is a no-op. |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1557 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1558 * @param executor The Executor implementation which will be used by |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1559 * abort |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1560 * @throws SQLException if a database access error occurs or the |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1561 * executor is null |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1562 * @throws SecurityException if a security manager exists and |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1563 * its checkPermission method denies calling abort |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1564 * @since 1.7 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1565 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1566 @Override |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
1567 public void abort(final Executor executor) throws SQLException { |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1568 if (closed) |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1569 return; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1570 if (executor == null) |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1571 throw new SQLException("executor is null", "M1M05"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1572 // this is really the simplest thing to do, it destroys |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1573 // everything (in particular the server connection) |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1574 close(); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1575 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1576 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1577 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1578 * Sets the maximum period a Connection or objects created from the |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1579 * Connection will wait for the database to reply to any one |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1580 * request. If any request remains unanswered, the waiting method |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1581 * will return with a SQLException, and the Connection or objects |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1582 * created from the Connection will be marked as closed. Any |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1583 * subsequent use of the objects, with the exception of the close, |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1584 * isClosed or Connection.isValid methods, will result in a |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1585 * SQLException. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1586 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1587 * @param executor The Executor implementation which will be used by |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1588 * setNetworkTimeout |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1589 * @param millis The time in milliseconds to wait for the |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1590 * database operation to complete |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1591 * @throws SQLException if a database access error occurs, this |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1592 * method is called on a closed connection, the executor is |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1593 * null, or the value specified for seconds is less than 0. |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1594 * @since 1.7 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1595 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1596 @Override |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
1597 public void setNetworkTimeout(final Executor executor, final int millis) throws SQLException { |
348
bcb9a99d399d
Add private checkNotClosed() method to check if the connection is not closed.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
345
diff
changeset
|
1598 checkNotClosed(); |
bcb9a99d399d
Add private checkNotClosed() method to check if the connection is not closed.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
345
diff
changeset
|
1599 // executor object is not used yet, so no need to test it. |
bcb9a99d399d
Add private checkNotClosed() method to check if the connection is not closed.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
345
diff
changeset
|
1600 // if (executor == null) |
bcb9a99d399d
Add private checkNotClosed() method to check if the connection is not closed.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
345
diff
changeset
|
1601 // throw new SQLException("executor is null", "M1M05"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1602 if (millis < 0) |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1603 throw new SQLException("milliseconds is less than zero", "M1M05"); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1604 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1605 try { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1606 server.setSoTimeout(millis); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1607 } catch (SocketException e) { |
144
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
136
diff
changeset
|
1608 throw new SQLNonTransientConnectionException(e.getMessage(), "08000"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1609 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1610 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1611 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1612 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1613 * Retrieves the number of milliseconds the driver will wait for a |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1614 * database request to complete. If the limit is exceeded, a |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1615 * SQLException is thrown. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1616 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1617 * @return the current timeout limit in milliseconds; zero means |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1618 * there is no limit |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1619 * @throws SQLException if a database access error occurs or |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1620 * this method is called on a closed Connection |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1621 * @since 1.7 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1622 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1623 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1624 public int getNetworkTimeout() throws SQLException { |
348
bcb9a99d399d
Add private checkNotClosed() method to check if the connection is not closed.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
345
diff
changeset
|
1625 checkNotClosed(); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1626 try { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1627 return server.getSoTimeout(); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1628 } catch (SocketException e) { |
144
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
136
diff
changeset
|
1629 throw new SQLNonTransientConnectionException(e.getMessage(), "08000"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1630 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1631 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1632 |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1633 //== end methods of interface java.sql.Connection |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1634 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1635 |
370
2ab474af487c
Add utility method to replace calls to x.replaceAll().replaceAll() in several places.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
350
diff
changeset
|
1636 //== internal helper methods which do not belong to the JDBC interface |
2ab474af487c
Add utility method to replace calls to x.replaceAll().replaceAll() in several places.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
350
diff
changeset
|
1637 |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
1638 /** |
194
1296dbcc4958
Resolved javadoc many errors and warnings, such as:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
186
diff
changeset
|
1639 * @return whether the JDBC BLOB type should be mapped to VARBINARY type. |
175
8700d9ef2ace
Added possibility via a connection property to let the JDBC driver
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
167
diff
changeset
|
1640 * This allows generic JDBC programs to fetch Blob data via getBytes() |
8700d9ef2ace
Added possibility via a connection property to let the JDBC driver
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
167
diff
changeset
|
1641 * instead of getBlob() and Blob.getBinaryStream() to reduce overhead. |
332
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1642 * It is called from: MonetResultSet and MonetPreparedStatement |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1643 */ |
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
|
1644 boolean mapBlobAsVarBinary() { |
175
8700d9ef2ace
Added possibility via a connection property to let the JDBC driver
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
167
diff
changeset
|
1645 return treatBlobAsVarBinary; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1646 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1647 |
175
8700d9ef2ace
Added possibility via a connection property to let the JDBC driver
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
167
diff
changeset
|
1648 /** |
194
1296dbcc4958
Resolved javadoc many errors and warnings, such as:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
186
diff
changeset
|
1649 * @return whether the JDBC CLOB type should be mapped to VARCHAR type. |
175
8700d9ef2ace
Added possibility via a connection property to let the JDBC driver
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
167
diff
changeset
|
1650 * This allows generic JDBC programs to fetch Clob data via getString() |
8700d9ef2ace
Added possibility via a connection property to let the JDBC driver
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
167
diff
changeset
|
1651 * instead of getClob() and Clob.getCharacterStream() to reduce overhead. |
332
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1652 * It is called from: MonetResultSet and MonetPreparedStatement |
175
8700d9ef2ace
Added possibility via a connection property to let the JDBC driver
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
167
diff
changeset
|
1653 */ |
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
|
1654 boolean mapClobAsVarChar() { |
175
8700d9ef2ace
Added possibility via a connection property to let the JDBC driver
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
167
diff
changeset
|
1655 return treatClobAsVarChar; |
8700d9ef2ace
Added possibility via a connection property to let the JDBC driver
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
167
diff
changeset
|
1656 } |
77
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
1657 |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
1658 /** |
348
bcb9a99d399d
Add private checkNotClosed() method to check if the connection is not closed.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
345
diff
changeset
|
1659 * Local helper method to test whether the Connection object is closed |
bcb9a99d399d
Add private checkNotClosed() method to check if the connection is not closed.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
345
diff
changeset
|
1660 * When closed it throws an SQLException |
bcb9a99d399d
Add private checkNotClosed() method to check if the connection is not closed.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
345
diff
changeset
|
1661 */ |
bcb9a99d399d
Add private checkNotClosed() method to check if the connection is not closed.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
345
diff
changeset
|
1662 private void checkNotClosed() throws SQLException { |
bcb9a99d399d
Add private checkNotClosed() method to check if the connection is not closed.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
345
diff
changeset
|
1663 if (closed) |
bcb9a99d399d
Add private checkNotClosed() method to check if the connection is not closed.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
345
diff
changeset
|
1664 throw new SQLException("Connection is closed", "M1M20"); |
bcb9a99d399d
Add private checkNotClosed() method to check if the connection is not closed.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
345
diff
changeset
|
1665 } |
bcb9a99d399d
Add private checkNotClosed() method to check if the connection is not closed.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
345
diff
changeset
|
1666 |
bcb9a99d399d
Add private checkNotClosed() method to check if the connection is not closed.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
345
diff
changeset
|
1667 /** |
332
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1668 * @return the MonetDB JDBC Connection URL (without user name and password). |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1669 * It is called from: getURL()in MonetDatabaseMetaData |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1670 */ |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1671 String getJDBCURL() { |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1672 final StringBuilder sb = new StringBuilder(128); |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1673 sb.append(MonetDriver.MONETURL).append(hostname) |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1674 .append(':').append(port) |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1675 .append('/').append(database); |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1676 if (lang == LANG_MAL) |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1677 sb.append("?language=mal"); |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1678 return sb.toString(); |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1679 } |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1680 |
370
2ab474af487c
Add utility method to replace calls to x.replaceAll().replaceAll() in several places.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
350
diff
changeset
|
1681 /** |
2ab474af487c
Add utility method to replace calls to x.replaceAll().replaceAll() in several places.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
350
diff
changeset
|
1682 * Utility method to escape all ocurrences of special characters |
2ab474af487c
Add utility method to replace calls to x.replaceAll().replaceAll() in several places.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
350
diff
changeset
|
1683 * (double slashes and single quotes) in a string literal |
2ab474af487c
Add utility method to replace calls to x.replaceAll().replaceAll() in several places.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
350
diff
changeset
|
1684 * It is called from: MonetDatabaseMetaData and MonetPreparedStatement |
2ab474af487c
Add utility method to replace calls to x.replaceAll().replaceAll() in several places.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
350
diff
changeset
|
1685 */ |
2ab474af487c
Add utility method to replace calls to x.replaceAll().replaceAll() in several places.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
350
diff
changeset
|
1686 final String escapeSpecialChars(final String in) { |
2ab474af487c
Add utility method to replace calls to x.replaceAll().replaceAll() in several places.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
350
diff
changeset
|
1687 String ret = in; |
2ab474af487c
Add utility method to replace calls to x.replaceAll().replaceAll() in several places.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
350
diff
changeset
|
1688 if (ret.contains("\\\\")) |
2ab474af487c
Add utility method to replace calls to x.replaceAll().replaceAll() in several places.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
350
diff
changeset
|
1689 // all double slashes in input need to be escaped. |
2ab474af487c
Add utility method to replace calls to x.replaceAll().replaceAll() in several places.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
350
diff
changeset
|
1690 ret = ret.replaceAll("\\\\", "\\\\\\\\"); |
2ab474af487c
Add utility method to replace calls to x.replaceAll().replaceAll() in several places.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
350
diff
changeset
|
1691 if (ret.contains("'")) |
2ab474af487c
Add utility method to replace calls to x.replaceAll().replaceAll() in several places.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
350
diff
changeset
|
1692 // all single quotes in input need to be escaped. |
2ab474af487c
Add utility method to replace calls to x.replaceAll().replaceAll() in several places.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
350
diff
changeset
|
1693 ret = ret.replaceAll("'", "\\\\'"); |
2ab474af487c
Add utility method to replace calls to x.replaceAll().replaceAll() in several places.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
350
diff
changeset
|
1694 return ret; |
2ab474af487c
Add utility method to replace calls to x.replaceAll().replaceAll() in several places.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
350
diff
changeset
|
1695 } |
2ab474af487c
Add utility method to replace calls to x.replaceAll().replaceAll() in several places.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
350
diff
changeset
|
1696 |
2ab474af487c
Add utility method to replace calls to x.replaceAll().replaceAll() in several places.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
350
diff
changeset
|
1697 |
407
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
1698 // Internal caches for 3 static mserver environment values, so they aren't queried from mserver again and again |
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
1699 private String env_current_user; |
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
1700 private String env_monet_version; |
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
1701 private int maxConnections; |
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
1702 private int databaseMajorVersion; |
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
1703 private int databaseMinorVersion; |
332
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1704 |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1705 /** |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1706 * Utility method to fetch 3 mserver environment values combined in one query for efficiency. |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1707 * We currently fetch the env values of: current_user, monet_version and max_clients. |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1708 * We cache them such that we do not need to query the server again and again. |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1709 */ |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1710 private synchronized void getEnvValues() throws SQLException { |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1711 Statement st = null; |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1712 ResultSet rs = null; |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1713 try { |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1714 st = createStatement(); |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1715 if (st != null) { |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1716 rs = st.executeQuery( |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1717 "SELECT \"name\", \"value\" FROM \"sys\".\"env\"()" + |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1718 " WHERE \"name\" IN ('monet_version', 'max_clients')" + |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1719 " UNION SELECT 'current_user' as \"name\", current_user as \"value\""); |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1720 if (rs != null) { |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1721 while (rs.next()) { |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1722 final String prop = rs.getString(1); |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1723 final String value = rs.getString(2); |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1724 if ("current_user".equals(prop)) { |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1725 env_current_user = value; |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1726 } else |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1727 if ("monet_version".equals(prop)) { |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1728 env_monet_version = value; |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1729 } else |
407
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
1730 if ("max_clients".equals(prop) && value != null) { |
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
1731 try { |
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
1732 maxConnections = Integer.parseInt(value); |
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
1733 } catch (NumberFormatException nfe) { |
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
1734 /* ignore */ |
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
1735 } |
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
1736 if (maxConnections <= 0) |
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
1737 maxConnections = 1; |
332
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1738 } |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1739 } |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1740 } |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1741 } |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1742 /* do not catch SQLException here, as we need to know it when it fails */ |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1743 } finally { |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1744 closeResultsetStatement(rs, st); |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1745 } |
407
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
1746 // for debug: System.out.println("Read: env_current_user: " + env_current_user + " env_monet_version: " + env_monet_version + " env_max_clients: " + maxConnections); |
332
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1747 } |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1748 |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1749 /** |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1750 * @return the current User Name. |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1751 * It is called from: MonetDatabaseMetaData |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1752 */ |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1753 String getUserName() throws SQLException { |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1754 if (env_current_user == null) |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1755 getEnvValues(); |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1756 return env_current_user; |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1757 } |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1758 |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1759 /** |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1760 * @return the MonetDB Database Server version string. |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1761 * It is called from: MonetDatabaseMetaData |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1762 */ |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1763 String getDatabaseProductVersion() throws SQLException { |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1764 if (env_monet_version == null) |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1765 getEnvValues(); |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1766 // always return a valid String to prevent NPE in getTables() and getTableTypes() |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1767 if (env_monet_version != null) |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1768 return env_monet_version; |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1769 return ""; |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1770 } |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1771 |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1772 /** |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1773 * @return the MonetDB Database Server major version number. |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1774 * It is called from: MonetDatabaseMetaData |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1775 */ |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1776 int getDatabaseMajorVersion() throws SQLException { |
407
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
1777 if (databaseMajorVersion == 0) { |
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
1778 if (env_monet_version == null) |
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
1779 getEnvValues(); |
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
1780 if (env_monet_version != null) { |
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
1781 try { |
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
1782 // from version string such as 11.33.9 extract number: 11 |
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
1783 final int start = env_monet_version.indexOf('.'); |
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
1784 databaseMajorVersion = Integer.parseInt((start >= 0) ? env_monet_version.substring(0, start) : env_monet_version); |
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
1785 } catch (NumberFormatException nfe) { |
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
1786 // ignore |
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
1787 } |
332
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1788 } |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1789 } |
407
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
1790 return databaseMajorVersion; |
332
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1791 } |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1792 |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1793 /** |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1794 * @return the MonetDB Database Server minor version number. |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1795 * It is called from: MonetDatabaseMetaData |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1796 */ |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1797 int getDatabaseMinorVersion() throws SQLException { |
407
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
1798 if (databaseMinorVersion == 0) { |
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
1799 if (env_monet_version == null) |
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
1800 getEnvValues(); |
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
1801 if (env_monet_version != null) { |
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
1802 try { |
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
1803 // from version string such as 11.33.9 extract number: 33 |
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
1804 int start = env_monet_version.indexOf('.'); |
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
1805 if (start >= 0) { |
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
1806 start++; |
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
1807 final int end = env_monet_version.indexOf('.', start); |
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
1808 databaseMinorVersion = Integer.parseInt((end > 0) ? env_monet_version.substring(start, end) : env_monet_version.substring(start)); |
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
1809 } |
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
1810 } catch (NumberFormatException nfe) { |
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
1811 // ignore |
332
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1812 } |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1813 } |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1814 } |
407
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
1815 return databaseMinorVersion; |
332
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1816 } |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1817 |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1818 /** |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1819 * @return the maximum number of active connections possible at one time; |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1820 * a result of zero means that there is no limit or the limit is not known |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1821 * It is called from: MonetDatabaseMetaData |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1822 */ |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1823 int getMaxConnections() throws SQLException { |
407
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
1824 if (maxConnections == 0) |
332
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1825 getEnvValues(); |
407
40a1db14dca5
Optimise code, reduce duplicate code, cache major and minor version nrs of connected database server and max nr of clients so conversion of strings to ints is only done once.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
406
diff
changeset
|
1826 return maxConnections; |
332
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1827 } |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1828 |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1829 |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1830 // Internal cache for determining if system table sys.privilege_codes (new as of Jul2017 release) exists on connected server |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1831 private boolean queriedPrivilege_codesTable = false; |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1832 private boolean hasPrivilege_codesTable = false; |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1833 /** |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1834 * Utility method to query the server to find out if it has |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1835 * the system table sys.privilege_codes (which is new as of Jul2017 release). |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1836 * The result is cached and reused, so that we only test the query once per connection. |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1837 * This method is used by methods from MonetDatabaseMetaData. |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1838 */ |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1839 boolean privilege_codesTableExists() { |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1840 if (!queriedPrivilege_codesTable) { |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1841 hasPrivilege_codesTable = existsSysTable("privilege_codes"); |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1842 queriedPrivilege_codesTable = true; // set flag, so the querying is done only at first invocation. |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1843 } |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1844 return hasPrivilege_codesTable; |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1845 } |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1846 |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1847 // Internal cache for determining if system table sys.comments (new as of Mar2018 release) exists on connected server |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1848 private boolean queriedCommentsTable = false; |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1849 private boolean hasCommentsTable = false; |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1850 /** |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1851 * Utility method to query the server to find out if it has |
215
71b039bc2d99
Added support for querying the sys.comments table for some meta data methods
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
214
diff
changeset
|
1852 * the system table sys.comments (which is new as of Mar2018 release). |
71b039bc2d99
Added support for querying the sys.comments table for some meta data methods
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
214
diff
changeset
|
1853 * The result is cached and reused, so that we only test the query once per connection. |
71b039bc2d99
Added support for querying the sys.comments table for some meta data methods
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
214
diff
changeset
|
1854 * This method is used by methods from MonetDatabaseMetaData. |
71b039bc2d99
Added support for querying the sys.comments table for some meta data methods
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
214
diff
changeset
|
1855 */ |
71b039bc2d99
Added support for querying the sys.comments table for some meta data methods
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
214
diff
changeset
|
1856 boolean commentsTableExists() { |
219
4572f0694fde
Improved DatabaseMetaData methods getTablePrivileges() and getColumnPrivileges() by returning also
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
215
diff
changeset
|
1857 if (!queriedCommentsTable) { |
4572f0694fde
Improved DatabaseMetaData methods getTablePrivileges() and getColumnPrivileges() by returning also
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
215
diff
changeset
|
1858 hasCommentsTable = existsSysTable("comments"); |
4572f0694fde
Improved DatabaseMetaData methods getTablePrivileges() and getColumnPrivileges() by returning also
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
215
diff
changeset
|
1859 queriedCommentsTable = true; // set flag, so the querying is done only at first invocation. |
4572f0694fde
Improved DatabaseMetaData methods getTablePrivileges() and getColumnPrivileges() by returning also
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
215
diff
changeset
|
1860 } |
4572f0694fde
Improved DatabaseMetaData methods getTablePrivileges() and getColumnPrivileges() by returning also
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
215
diff
changeset
|
1861 return hasCommentsTable; |
4572f0694fde
Improved DatabaseMetaData methods getTablePrivileges() and getColumnPrivileges() by returning also
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
215
diff
changeset
|
1862 } |
215
71b039bc2d99
Added support for querying the sys.comments table for some meta data methods
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
214
diff
changeset
|
1863 |
219
4572f0694fde
Improved DatabaseMetaData methods getTablePrivileges() and getColumnPrivileges() by returning also
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
215
diff
changeset
|
1864 |
4572f0694fde
Improved DatabaseMetaData methods getTablePrivileges() and getColumnPrivileges() by returning also
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
215
diff
changeset
|
1865 /** |
332
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1866 * Internal utility method to query the server to find out if it has a specific system table sys.<tablename>. |
219
4572f0694fde
Improved DatabaseMetaData methods getTablePrivileges() and getColumnPrivileges() by returning also
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
215
diff
changeset
|
1867 */ |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
1868 private boolean existsSysTable(final String tablename) { |
219
4572f0694fde
Improved DatabaseMetaData methods getTablePrivileges() and getColumnPrivileges() by returning also
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
215
diff
changeset
|
1869 boolean exists = false; |
215
71b039bc2d99
Added support for querying the sys.comments table for some meta data methods
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
214
diff
changeset
|
1870 Statement stmt = null; |
71b039bc2d99
Added support for querying the sys.comments table for some meta data methods
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
214
diff
changeset
|
1871 ResultSet rs = null; |
71b039bc2d99
Added support for querying the sys.comments table for some meta data methods
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
214
diff
changeset
|
1872 try { |
71b039bc2d99
Added support for querying the sys.comments table for some meta data methods
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
214
diff
changeset
|
1873 stmt = createStatement(); |
71b039bc2d99
Added support for querying the sys.comments table for some meta data methods
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
214
diff
changeset
|
1874 if (stmt != null) { |
219
4572f0694fde
Improved DatabaseMetaData methods getTablePrivileges() and getColumnPrivileges() by returning also
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
215
diff
changeset
|
1875 rs = stmt.executeQuery("SELECT id FROM sys._tables WHERE name = '" |
4572f0694fde
Improved DatabaseMetaData methods getTablePrivileges() and getColumnPrivileges() by returning also
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
215
diff
changeset
|
1876 + tablename |
4572f0694fde
Improved DatabaseMetaData methods getTablePrivileges() and getColumnPrivileges() by returning also
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
215
diff
changeset
|
1877 + "' AND schema_id IN (SELECT id FROM sys.schemas WHERE name = 'sys')"); |
215
71b039bc2d99
Added support for querying the sys.comments table for some meta data methods
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
214
diff
changeset
|
1878 if (rs != null) { |
219
4572f0694fde
Improved DatabaseMetaData methods getTablePrivileges() and getColumnPrivileges() by returning also
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
215
diff
changeset
|
1879 exists = rs.next(); // if a row is available it exists, else not |
215
71b039bc2d99
Added support for querying the sys.comments table for some meta data methods
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
214
diff
changeset
|
1880 } |
71b039bc2d99
Added support for querying the sys.comments table for some meta data methods
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
214
diff
changeset
|
1881 } |
71b039bc2d99
Added support for querying the sys.comments table for some meta data methods
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
214
diff
changeset
|
1882 } catch (SQLException se) { |
71b039bc2d99
Added support for querying the sys.comments table for some meta data methods
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
214
diff
changeset
|
1883 /* ignore */ |
71b039bc2d99
Added support for querying the sys.comments table for some meta data methods
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
214
diff
changeset
|
1884 } finally { |
300
8cc3b51d1984
Add a utility method to close objects ignoring any possible SQLExceptions thrown.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
296
diff
changeset
|
1885 closeResultsetStatement(rs, stmt); |
215
71b039bc2d99
Added support for querying the sys.comments table for some meta data methods
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
214
diff
changeset
|
1886 } |
332
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1887 // for debug: System.out.println("testTableExists(" + tablename + ") returns: " + exists); |
219
4572f0694fde
Improved DatabaseMetaData methods getTablePrivileges() and getColumnPrivileges() by returning also
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
215
diff
changeset
|
1888 return exists; |
215
71b039bc2d99
Added support for querying the sys.comments table for some meta data methods
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
214
diff
changeset
|
1889 } |
71b039bc2d99
Added support for querying the sys.comments table for some meta data methods
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
214
diff
changeset
|
1890 |
71b039bc2d99
Added support for querying the sys.comments table for some meta data methods
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
214
diff
changeset
|
1891 /** |
300
8cc3b51d1984
Add a utility method to close objects ignoring any possible SQLExceptions thrown.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
296
diff
changeset
|
1892 * Closes a ResultSet and/or Statement object without throwing any SQLExceptions |
8cc3b51d1984
Add a utility method to close objects ignoring any possible SQLExceptions thrown.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
296
diff
changeset
|
1893 * It can be used in the finally clause after creating a Statement and |
8cc3b51d1984
Add a utility method to close objects ignoring any possible SQLExceptions thrown.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
296
diff
changeset
|
1894 * (optionally) executed a query which produced a ResultSet. |
8cc3b51d1984
Add a utility method to close objects ignoring any possible SQLExceptions thrown.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
296
diff
changeset
|
1895 * |
8cc3b51d1984
Add a utility method to close objects ignoring any possible SQLExceptions thrown.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
296
diff
changeset
|
1896 * @param rs ResultSet object to be closed. It may be null |
8cc3b51d1984
Add a utility method to close objects ignoring any possible SQLExceptions thrown.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
296
diff
changeset
|
1897 * @param st Statement object to be closed. It may be null |
8cc3b51d1984
Add a utility method to close objects ignoring any possible SQLExceptions thrown.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
296
diff
changeset
|
1898 */ |
8cc3b51d1984
Add a utility method to close objects ignoring any possible SQLExceptions thrown.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
296
diff
changeset
|
1899 static final void closeResultsetStatement(final ResultSet rs, final Statement st) { |
8cc3b51d1984
Add a utility method to close objects ignoring any possible SQLExceptions thrown.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
296
diff
changeset
|
1900 if (rs != null) { |
8cc3b51d1984
Add a utility method to close objects ignoring any possible SQLExceptions thrown.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
296
diff
changeset
|
1901 try { |
8cc3b51d1984
Add a utility method to close objects ignoring any possible SQLExceptions thrown.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
296
diff
changeset
|
1902 rs.close(); |
8cc3b51d1984
Add a utility method to close objects ignoring any possible SQLExceptions thrown.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
296
diff
changeset
|
1903 } catch (SQLException e) { /* ignore */ } |
8cc3b51d1984
Add a utility method to close objects ignoring any possible SQLExceptions thrown.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
296
diff
changeset
|
1904 } |
8cc3b51d1984
Add a utility method to close objects ignoring any possible SQLExceptions thrown.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
296
diff
changeset
|
1905 if (st != null) { |
8cc3b51d1984
Add a utility method to close objects ignoring any possible SQLExceptions thrown.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
296
diff
changeset
|
1906 try { |
8cc3b51d1984
Add a utility method to close objects ignoring any possible SQLExceptions thrown.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
296
diff
changeset
|
1907 st.close(); |
8cc3b51d1984
Add a utility method to close objects ignoring any possible SQLExceptions thrown.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
296
diff
changeset
|
1908 } catch (SQLException e) { /* ignore */ } |
8cc3b51d1984
Add a utility method to close objects ignoring any possible SQLExceptions thrown.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
296
diff
changeset
|
1909 } |
8cc3b51d1984
Add a utility method to close objects ignoring any possible SQLExceptions thrown.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
296
diff
changeset
|
1910 } |
8cc3b51d1984
Add a utility method to close objects ignoring any possible SQLExceptions thrown.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
296
diff
changeset
|
1911 |
8cc3b51d1984
Add a utility method to close objects ignoring any possible SQLExceptions thrown.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
296
diff
changeset
|
1912 /** |
77
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
1913 * Sends the given string to MonetDB as special transaction command. |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
1914 * All possible returned information is discarded. |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
1915 * Encountered errors are reported. |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
1916 * |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
1917 * @param command the exact string to send to MonetDB |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
1918 * @throws SQLException if an IO exception or a database error occurs |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
1919 */ |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
1920 private void sendTransactionCommand(final String command) throws SQLException { |
77
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
1921 // create a container for the result |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
1922 final ResponseList l = new ResponseList(0, 0, ResultSet.FETCH_FORWARD, ResultSet.CONCUR_READ_ONLY); |
77
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
1923 // send the appropriate query string to the database |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
1924 try { |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
1925 l.processQuery(command); |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
1926 } finally { |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
1927 l.close(); |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
1928 } |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
1929 } |
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
1930 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1931 /** |
278
1d6062d94377
Reduce duplicate code.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
271
diff
changeset
|
1932 * Sends the given string to MonetDB as regular SQL statement/query using queryTempl |
1d6062d94377
Reduce duplicate code.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
271
diff
changeset
|
1933 * Making sure there is a prompt after the command is sent. All possible |
1d6062d94377
Reduce duplicate code.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
271
diff
changeset
|
1934 * returned information is discarded. Encountered errors are reported. |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1935 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1936 * @param command the exact string to send to MonetDB |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1937 * @throws SQLException if an IO exception or a database error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1938 */ |
278
1d6062d94377
Reduce duplicate code.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
271
diff
changeset
|
1939 private void sendIndependentCommand(String command) throws SQLException { |
1d6062d94377
Reduce duplicate code.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
271
diff
changeset
|
1940 sendCommand(command, true); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1941 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1942 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1943 /** |
278
1d6062d94377
Reduce duplicate code.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
271
diff
changeset
|
1944 * Sends the given string to MonetDB as control statement using commandTempl |
1d6062d94377
Reduce duplicate code.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
271
diff
changeset
|
1945 * Making sure there is a prompt after the command is sent. All possible |
1d6062d94377
Reduce duplicate code.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
271
diff
changeset
|
1946 * returned information is discarded. Encountered errors are reported. |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1947 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1948 * @param command the exact string to send to MonetDB |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1949 * @throws SQLException if an IO exception or a database error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1950 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1951 void sendControlCommand(String command) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1952 // send X command |
278
1d6062d94377
Reduce duplicate code.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
271
diff
changeset
|
1953 sendCommand(command, false); |
1d6062d94377
Reduce duplicate code.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
271
diff
changeset
|
1954 } |
1d6062d94377
Reduce duplicate code.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
271
diff
changeset
|
1955 |
1d6062d94377
Reduce duplicate code.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
271
diff
changeset
|
1956 /** |
1d6062d94377
Reduce duplicate code.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
271
diff
changeset
|
1957 * Sends the given string to MonetDB as command/query using commandTempl or queryTempl |
1d6062d94377
Reduce duplicate code.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
271
diff
changeset
|
1958 * Making sure there is a prompt after the command is sent. All possible |
332
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1959 * returned information is discarded. Encountered errors are reported. |
278
1d6062d94377
Reduce duplicate code.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
271
diff
changeset
|
1960 * |
1d6062d94377
Reduce duplicate code.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
271
diff
changeset
|
1961 * @param command the exact string to send to MonetDB |
332
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1962 * @param usequeryTempl send the command using queryTempl or else using commandTempl |
278
1d6062d94377
Reduce duplicate code.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
271
diff
changeset
|
1963 * @throws SQLException if an IO exception or a database error occurs |
1d6062d94377
Reduce duplicate code.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
271
diff
changeset
|
1964 */ |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
1965 private void sendCommand(final String command, final boolean usequeryTempl) throws SQLException { |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1966 synchronized (server) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1967 try { |
332
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1968 out.writeLine(usequeryTempl ? (queryTempl[0] + command + queryTempl[1]) |
e8962bdaa206
Moved utility methods and associated caches from DatabaseMetaData to Connection object.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
324
diff
changeset
|
1969 : (commandTempl[0] + command + commandTempl[1]) ); |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
1970 final String error = in.waitForPrompt(); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1971 if (error != null) |
144
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
136
diff
changeset
|
1972 throw new SQLException(error.substring(6), error.substring(0, 5)); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1973 } catch (SocketTimeoutException e) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1974 close(); // JDBC 4.1 semantics, abort() |
144
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
136
diff
changeset
|
1975 throw new SQLNonTransientConnectionException("connection timed out", "08M33"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1976 } catch (IOException e) { |
144
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
136
diff
changeset
|
1977 throw new SQLNonTransientConnectionException(e.getMessage(), "08000"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1978 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1979 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1980 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1981 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1982 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1983 * Adds a warning to the pile of warnings this Connection object |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1984 * has. If there were no warnings (or clearWarnings was called) |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1985 * this warning will be the first, otherwise this warning will get |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1986 * appended to the current warning. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1987 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1988 * @param reason the warning message |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1989 */ |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
1990 private final void addWarning(final String reason, final String sqlstate) { |
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
1991 final SQLWarning warng = new SQLWarning(reason, sqlstate); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1992 if (warnings == null) { |
186
4767b005a531
Making variables private where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
184
diff
changeset
|
1993 warnings = warng; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1994 } else { |
186
4767b005a531
Making variables private where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
184
diff
changeset
|
1995 warnings.setNextWarning(warng); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1996 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1997 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1998 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
1999 /** the default number of rows that are (attempted to) read at once */ |
186
4767b005a531
Making variables private where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
184
diff
changeset
|
2000 private static final int DEF_FETCHSIZE = 250; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2001 /** The sequence counter */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2002 private static int seqCounter = 0; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2003 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2004 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2005 * A Response is a message sent by the server to indicate some |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2006 * action has taken place, and possible results of that action. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2007 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2008 // {{{ interface Response |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2009 interface Response { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2010 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2011 * Adds a line to the underlying Response implementation. |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
2012 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2013 * @param line the header line as String |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2014 * @param linetype the line type according to the MAPI protocol |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2015 * @return a non-null String if the line is invalid, |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2016 * or additional lines are not allowed. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2017 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2018 public abstract String addLine(String line, int linetype); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2019 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2020 /** |
288
f412032e3b43
Correcting typo
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
286
diff
changeset
|
2021 * Returns whether this Response expects more lines to be added |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2022 * to it. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2023 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2024 * @return true if a next line should be added, false otherwise |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2025 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2026 public abstract boolean wantsMore(); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2027 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2028 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2029 * Indicates that no more header lines will be added to this |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2030 * Response implementation. |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
2031 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2032 * @throws SQLException if the contents of the Response is not |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2033 * consistent or sufficient. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2034 */ |
324
0b01771d5f8a
Method Response.complete() is never used or needed. Disabled the code from the interface and its implementations.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
300
diff
changeset
|
2035 /* MvD: disabled not used/needed code |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2036 public abstract void complete() throws SQLException; |
324
0b01771d5f8a
Method Response.complete() is never used or needed. Disabled the code from the interface and its implementations.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
300
diff
changeset
|
2037 */ |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2038 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2039 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2040 * Instructs the Response implementation to close and do the |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2041 * necessary clean up procedures. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2042 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2043 public abstract void close(); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2044 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2045 // }}} |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2046 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2047 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2048 * The ResultSetResponse represents a tabular result sent by the |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2049 * server. This is typically an SQL table. The MAPI headers of the |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2050 * Response look like: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2051 * <pre> |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2052 * &1 1 28 2 10 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2053 * # name, value # name |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2054 * # varchar, varchar # type |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2055 * </pre> |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2056 * there the first line consists out of<br /> |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2057 * <tt>&"qt" "id" "tc" "cc" "rc"</tt>. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2058 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2059 // {{{ ResultSetResponse class implementation |
296
c5efd6e661e5
Add "final" keyword to classes, method arguments and local variables where possible.`
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
295
diff
changeset
|
2060 final class ResultSetResponse implements Response { |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2061 /** The number of columns in this result */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2062 public final int columncount; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2063 /** The total number of rows this result set has */ |
377
8a813f5cef1b
Extend StartOfHeaderParser with method getNextAsLong() and change type of tuplecount to long.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
376
diff
changeset
|
2064 public final long tuplecount; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2065 /** The numbers of rows to retrieve per DataBlockResponse */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2066 private int cacheSize; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2067 /** The table ID of this result */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2068 public final int id; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2069 /** The names of the columns in this result */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2070 private String[] name; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2071 /** The types of the columns in this result */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2072 private String[] type; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2073 /** The max string length for each column in this result */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2074 private int[] columnLengths; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2075 /** The table for each column in this result */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2076 private String[] tableNames; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2077 /** The query sequence number */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2078 private final int seqnr; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2079 /** A List of result blocks (chunks of size fetchSize/cacheSize) */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2080 private DataBlockResponse[] resultBlocks; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2081 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2082 /** Whether this Response is closed */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2083 private boolean closed; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2084 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2085 /** The Connection that we should use when requesting a new block */ |
286
d430f8adbf1b
Add keyword "final" to those variables which do not change after first assigment.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
285
diff
changeset
|
2086 private final MonetConnection.ResponseList parent; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2087 /** Whether the fetchSize was explitly set by the user */ |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2088 private final boolean cacheSizeSetExplicitly; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2089 /** Whether we should send an Xclose command to the server |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2090 * if we close this Response */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2091 private boolean destroyOnClose; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2092 /** the offset to be used on Xexport queries */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2093 private int blockOffset = 0; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2094 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2095 /** A parser for header lines */ |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2096 private final HeaderLineParser hlp; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2097 |
286
d430f8adbf1b
Add keyword "final" to those variables which do not change after first assigment.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
285
diff
changeset
|
2098 /** A boolean array telling whether the headers are set or not */ |
d430f8adbf1b
Add keyword "final" to those variables which do not change after first assigment.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
285
diff
changeset
|
2099 private final boolean[] isSet; |
186
4767b005a531
Making variables private where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
184
diff
changeset
|
2100 private static final int NAMES = 0; |
4767b005a531
Making variables private where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
184
diff
changeset
|
2101 private static final int TYPES = 1; |
4767b005a531
Making variables private where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
184
diff
changeset
|
2102 private static final int TABLES = 2; |
4767b005a531
Making variables private where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
184
diff
changeset
|
2103 private static final int LENS = 3; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2104 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2105 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2106 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2107 * Sole constructor, which requires a MonetConnection parent to |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2108 * be given. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2109 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2110 * @param id the ID of the result set |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2111 * @param tuplecount the total number of tuples in the result set |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2112 * @param columncount the number of columns in the result set |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2113 * @param rowcount the number of rows in the current block |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2114 * @param parent the parent that created this Response and will |
144
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
136
diff
changeset
|
2115 * supply new result blocks when necessary |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2116 * @param seq the query sequence number |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2117 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2118 ResultSetResponse( |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2119 final int id, |
377
8a813f5cef1b
Extend StartOfHeaderParser with method getNextAsLong() and change type of tuplecount to long.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
376
diff
changeset
|
2120 final long tuplecount, |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2121 final int columncount, |
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2122 final int rowcount, |
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2123 final MonetConnection.ResponseList parent, |
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2124 final int seq) |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2125 throws SQLException |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2126 { |
286
d430f8adbf1b
Add keyword "final" to those variables which do not change after first assigment.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
285
diff
changeset
|
2127 isSet = new boolean[4]; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2128 this.parent = parent; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2129 if (parent.cachesize == 0) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2130 /* Below we have to calculate how many "chunks" we need |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2131 * to allocate to store the entire result. However, if |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2132 * the user didn't set a cache size, as in this case, we |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2133 * need to stick to our defaults. */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2134 cacheSize = MonetConnection.DEF_FETCHSIZE; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2135 cacheSizeSetExplicitly = false; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2136 } else { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2137 cacheSize = parent.cachesize; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2138 cacheSizeSetExplicitly = true; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2139 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2140 /* So far, so good. Now the problem with EXPLAIN, DOT, etc |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2141 * queries is, that they don't support any block fetching, |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2142 * so we need to always fetch everything at once. For that |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2143 * reason, the cache size is here set to the rowcount if |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2144 * it's larger, such that we do a full fetch at once. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2145 * (Because we always set a reply_size, we can only get a |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2146 * larger rowcount from the server if it doesn't paginate, |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2147 * because it's a pseudo SQL result.) */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2148 if (rowcount > cacheSize) |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2149 cacheSize = rowcount; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2150 seqnr = seq; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2151 closed = false; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2152 destroyOnClose = id > 0 && tuplecount > rowcount; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2153 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2154 this.id = id; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2155 this.tuplecount = tuplecount; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2156 this.columncount = columncount; |
377
8a813f5cef1b
Extend StartOfHeaderParser with method getNextAsLong() and change type of tuplecount to long.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
376
diff
changeset
|
2157 this.resultBlocks = new DataBlockResponse[(int)(tuplecount / cacheSize) + 1]; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2158 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2159 hlp = new HeaderLineParser(columncount); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2160 |
286
d430f8adbf1b
Add keyword "final" to those variables which do not change after first assigment.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
285
diff
changeset
|
2161 resultBlocks[0] = new DataBlockResponse(rowcount, parent.rstype == ResultSet.TYPE_FORWARD_ONLY); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2162 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2163 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2164 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2165 * Parses the given string and changes the value of the matching |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2166 * header appropriately, or passes it on to the underlying |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2167 * DataResponse. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2168 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2169 * @param tmpLine the string that contains the header |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2170 * @return a non-null String if the header cannot be parsed or |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2171 * is unknown |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2172 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2173 // {{{ addLine |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2174 @Override |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2175 public String addLine(final String tmpLine, final int linetype) { |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2176 if (isSet[LENS] && isSet[TYPES] && isSet[TABLES] && isSet[NAMES]) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2177 return resultBlocks[0].addLine(tmpLine, linetype); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2178 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2179 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2180 if (linetype != BufferedMCLReader.HEADER) |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2181 return "header expected, got: " + tmpLine; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2182 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2183 // depending on the name of the header, we continue |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2184 try { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2185 switch (hlp.parse(tmpLine)) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2186 case HeaderLineParser.NAME: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2187 name = hlp.values.clone(); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2188 isSet[NAMES] = true; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2189 break; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2190 case HeaderLineParser.LENGTH: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2191 columnLengths = hlp.intValues.clone(); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2192 isSet[LENS] = true; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2193 break; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2194 case HeaderLineParser.TYPE: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2195 type = hlp.values.clone(); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2196 isSet[TYPES] = true; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2197 break; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2198 case HeaderLineParser.TABLE: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2199 tableNames = hlp.values.clone(); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2200 isSet[TABLES] = true; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2201 break; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2202 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2203 } catch (MCLParseException e) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2204 return e.getMessage(); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2205 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2206 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2207 // all is well |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2208 return null; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2209 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2210 // }}} |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2211 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2212 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2213 * Returns whether this ResultSetResponse needs more lines. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2214 * This method returns true if not all headers are set, or the |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2215 * first DataBlockResponse reports to want more. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2216 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2217 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2218 public boolean wantsMore() { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2219 if (isSet[LENS] && isSet[TYPES] && isSet[TABLES] && isSet[NAMES]) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2220 return resultBlocks[0].wantsMore(); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2221 } else { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2222 return true; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2223 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2224 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2225 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2226 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2227 * Returns an array of Strings containing the values between |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2228 * ',\t' separators. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2229 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2230 * @param chrLine a character array holding the input data |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2231 * @param start where the relevant data starts |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2232 * @param stop where the relevant data stops |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2233 * @return an array of Strings |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2234 */ |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2235 private final String[] getValues(final char[] chrLine, int start, final int stop) { |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2236 int elem = 0; |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2237 final String[] values = new String[columncount]; |
77
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
2238 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2239 for (int i = start; i < stop; i++) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2240 if (chrLine[i] == '\t' && chrLine[i - 1] == ',') { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2241 values[elem++] = |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2242 new String(chrLine, start, i - 1 - start); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2243 start = i + 1; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2244 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2245 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2246 // at the left over part |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2247 values[elem++] = new String(chrLine, start, stop - start); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2248 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2249 return values; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2250 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2251 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2252 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2253 * Adds the given DataBlockResponse to this ResultSetResponse at |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2254 * the given block position. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2255 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2256 * @param offset the offset number of rows for this block |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2257 * @param rr the DataBlockResponse to add |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2258 */ |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2259 void addDataBlockResponse(final int offset, final DataBlockResponse rr) { |
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2260 final int block = (offset - blockOffset) / cacheSize; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2261 resultBlocks[block] = rr; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2262 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2263 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2264 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2265 * Marks this Response as being completed. A complete Response |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2266 * needs to be consistent with regard to its internal data. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2267 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2268 * @throws SQLException if the data currently in this Response is not |
144
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
136
diff
changeset
|
2269 * sufficient to be consistant |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2270 */ |
324
0b01771d5f8a
Method Response.complete() is never used or needed. Disabled the code from the interface and its implementations.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
300
diff
changeset
|
2271 /* MvD: disabled not used/needed code |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2272 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2273 public void complete() throws SQLException { |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2274 final StringBuilder err = new StringBuilder(99); |
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2275 if (!isSet[NAMES]) err.append("name header missing\n"); |
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2276 if (!isSet[TYPES]) err.append("type header missing\n"); |
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2277 if (!isSet[TABLES]) err.append("table name header missing\n"); |
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2278 if (!isSet[LENS]) err.append("column width header missing\n"); |
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2279 if (err.length() > 0) |
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2280 throw new SQLException(err.toString(), "M0M10"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2281 } |
324
0b01771d5f8a
Method Response.complete() is never used or needed. Disabled the code from the interface and its implementations.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
300
diff
changeset
|
2282 */ |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2283 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2284 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2285 * Returns the names of the columns |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2286 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2287 * @return the names of the columns |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2288 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2289 String[] getNames() { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2290 return name; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2291 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2292 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2293 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2294 * Returns the types of the columns |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2295 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2296 * @return the types of the columns |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2297 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2298 String[] getTypes() { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2299 return type; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2300 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2301 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2302 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2303 * Returns the tables of the columns |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2304 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2305 * @return the tables of the columns |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2306 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2307 String[] getTableNames() { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2308 return tableNames; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2309 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2310 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2311 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2312 * Returns the lengths of the columns |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2313 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2314 * @return the lengths of the columns |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2315 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2316 int[] getColumnLengths() { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2317 return columnLengths; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2318 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2319 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2320 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2321 * Returns the cache size used within this Response |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2322 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2323 * @return the cache size |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2324 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2325 int getCacheSize() { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2326 return cacheSize; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2327 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2328 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2329 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2330 * Returns the current block offset |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2331 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2332 * @return the current block offset |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2333 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2334 int getBlockOffset() { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2335 return blockOffset; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2336 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2337 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2338 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2339 * Returns the ResultSet type, FORWARD_ONLY or not. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2340 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2341 * @return the ResultSet type |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2342 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2343 int getRSType() { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2344 return parent.rstype; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2345 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2346 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2347 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2348 * Returns the concurrency of the ResultSet. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2349 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2350 * @return the ResultSet concurrency |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2351 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2352 int getRSConcur() { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2353 return parent.rsconcur; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2354 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2355 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2356 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2357 * Returns a line from the cache. If the line is already present in the |
136
4320e6891536
Replace AssertionError() with SQLException().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
2358 * cache, it is returned, if not appropriate actions are taken to make |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2359 * sure the right block is being fetched and as soon as the requested |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2360 * line is fetched it is returned. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2361 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2362 * @param row the row in the result set to return |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2363 * @return the exact row read as requested or null if the requested row |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2364 * is out of the scope of the result set |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2365 * @throws SQLException if an database error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2366 */ |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2367 String getLine(final int row) throws SQLException { |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2368 if (row >= tuplecount || row < 0) |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2369 return null; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2370 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2371 int block = (row - blockOffset) / cacheSize; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2372 int blockLine = (row - blockOffset) % cacheSize; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2373 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2374 // do we have the right block loaded? (optimistic try) |
214
b8c007e86694
Improve readability
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
2375 DataBlockResponse rawr = resultBlocks[block]; |
b8c007e86694
Improve readability
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
2376 if (rawr == null) { |
b8c007e86694
Improve readability
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
200
diff
changeset
|
2377 // load block |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2378 /// TODO: ponder about a maximum number of blocks to keep |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2379 /// in memory when dealing with random access to |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2380 /// reduce memory blow-up |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2381 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2382 // if we're running forward only, we can discard the old |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2383 // block loaded |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2384 if (parent.rstype == ResultSet.TYPE_FORWARD_ONLY) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2385 for (int i = 0; i < block; i++) |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2386 resultBlocks[i] = null; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2387 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2388 if (MonetConnection.seqCounter - 1 == seqnr && |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2389 !cacheSizeSetExplicitly && |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2390 tuplecount - row > cacheSize && |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2391 cacheSize < MonetConnection.DEF_FETCHSIZE * 10) |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2392 { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2393 // there has no query been issued after this |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2394 // one, so we can consider this an uninterrupted |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2395 // continuation request. Let's once increase |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2396 // the cacheSize as it was not explicitly set, |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2397 // since the chances are high that we won't |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2398 // bother anyone else by doing so, and just |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2399 // gaining some performance. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2400 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2401 // store the previous position in the |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2402 // blockOffset variable |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2403 blockOffset += cacheSize; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2404 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2405 // increase the cache size (a lot) |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2406 cacheSize *= 10; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2407 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2408 // by changing the cacheSize, we also |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2409 // change the block measures. Luckily |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2410 // we don't care about previous blocks |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2411 // because we have a forward running |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2412 // pointer only. However, we do have |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2413 // to recalculate the block number, to |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2414 // ensure the next call to find this |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2415 // new block. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2416 block = (row - blockOffset) / cacheSize; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2417 blockLine = (row - blockOffset) % cacheSize; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2418 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2419 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2420 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2421 // ok, need to fetch cache block first |
136
4320e6891536
Replace AssertionError() with SQLException().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
2422 parent.executeQuery(commandTempl, |
4320e6891536
Replace AssertionError() with SQLException().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
2423 "export " + id + " " + ((block * cacheSize) + blockOffset) + " " + cacheSize); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2424 rawr = resultBlocks[block]; |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
2425 if (rawr == null) |
136
4320e6891536
Replace AssertionError() with SQLException().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
90
diff
changeset
|
2426 throw new SQLException("resultBlocks[" + block + "] should have been fetched by now", "M0M10"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2427 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2428 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2429 return rawr.getRow(blockLine); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2430 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2431 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2432 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2433 * Closes this Response by sending an Xclose to the server indicating |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2434 * that the result can be closed at the server side as well. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2435 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2436 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2437 public void close() { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2438 if (closed) return; |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
2439 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2440 // send command to server indicating we're done with this |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2441 // result only if we had an ID in the header and this result |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2442 // was larger than the reply size |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2443 try { |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
2444 if (destroyOnClose) |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
2445 sendControlCommand("close " + id); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2446 } catch (SQLException e) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2447 // probably a connection error... |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2448 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2449 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2450 // close the data block associated with us |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2451 for (int i = 1; i < resultBlocks.length; i++) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2452 DataBlockResponse r = resultBlocks[i]; |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
2453 if (r != null) |
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
2454 r.close(); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2455 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2456 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2457 closed = true; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2458 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2459 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2460 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2461 * Returns whether this Response is closed |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2462 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2463 * @return whether this Response is closed |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2464 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2465 boolean isClosed() { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2466 return closed; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2467 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2468 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2469 // }}} |
77
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
2470 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2471 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2472 * The DataBlockResponse is tabular data belonging to a |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2473 * ResultSetResponse. Tabular data from the server typically looks |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2474 * like: |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2475 * <pre> |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2476 * [ "value", 56 ] |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2477 * </pre> |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2478 * where each column is separated by ",\t" and each tuple surrounded |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2479 * by brackets ("[" and "]"). A DataBlockResponse object holds the |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2480 * raw data as read from the server, in a parsed manner, ready for |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2481 * easy retrieval. |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
2482 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2483 * This object is not intended to be queried by multiple threads |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2484 * synchronously. It is designed to work for one thread retrieving |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2485 * rows from it. When multiple threads will retrieve rows from this |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2486 * object, it is possible for threads to get the same data. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2487 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2488 // {{{ DataBlockResponse class implementation |
296
c5efd6e661e5
Add "final" keyword to classes, method arguments and local variables where possible.`
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
295
diff
changeset
|
2489 private final static class DataBlockResponse implements Response { |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2490 /** The String array to keep the data in */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2491 private final String[] data; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2492 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2493 /** The counter which keeps the current position in the data array */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2494 private int pos; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2495 /** Whether we can discard lines as soon as we have read them */ |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2496 private final boolean forwardOnly; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2497 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2498 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2499 * Constructs a DataBlockResponse object |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2500 * @param size the size of the data array to create |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2501 * @param forward whether this is a forward only result |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2502 */ |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2503 DataBlockResponse(final int size, final boolean forward) { |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2504 pos = -1; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2505 data = new String[size]; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2506 forwardOnly = forward; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2507 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2508 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2509 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2510 * addLine adds a String of data to this object's data array. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2511 * Note that an IndexOutOfBoundsException can be thrown when an |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2512 * attempt is made to add more than the original construction size |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2513 * specified. |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
2514 * |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2515 * @param line the header line as String |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2516 * @param linetype the line type according to the MAPI protocol |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2517 * @return a non-null String if the line is invalid, |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2518 * or additional lines are not allowed. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2519 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2520 @Override |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2521 public String addLine(final String line, final int linetype) { |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2522 if (linetype != BufferedMCLReader.RESULT) |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2523 return "protocol violation: unexpected line in data block: " + line; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2524 // add to the backing array |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2525 data[++pos] = line; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2526 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2527 // all is well |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2528 return null; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2529 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2530 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2531 /** |
288
f412032e3b43
Correcting typo
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
286
diff
changeset
|
2532 * Returns whether this Response expects more lines to be added |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2533 * to it. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2534 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2535 * @return true if a next line should be added, false otherwise |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2536 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2537 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2538 public boolean wantsMore() { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2539 // remember: pos is the value already stored |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2540 return pos + 1 < data.length; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2541 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2542 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2543 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2544 * Indicates that no more header lines will be added to this |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2545 * Response implementation. In most cases this is a redundant |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2546 * operation because the data array is full. However... it can |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2547 * happen that this is NOT the case! |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2548 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2549 * @throws SQLException if not all rows are filled |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2550 */ |
324
0b01771d5f8a
Method Response.complete() is never used or needed. Disabled the code from the interface and its implementations.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
300
diff
changeset
|
2551 /* MvD: disabled not used/needed code |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2552 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2553 public void complete() throws SQLException { |
45
c2bf983dc79b
Implemented Connection methods: getClientInfo(name) and getClientInfo().
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
25
diff
changeset
|
2554 if ((pos + 1) != data.length) |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2555 throw new SQLException("Inconsistent state detected! Current block capacity: " |
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2556 + data.length + ", block usage: " + (pos + 1) |
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2557 + ". Did MonetDB send what it promised to?", "M0M10"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2558 } |
324
0b01771d5f8a
Method Response.complete() is never used or needed. Disabled the code from the interface and its implementations.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
300
diff
changeset
|
2559 */ |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2560 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2561 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2562 * Instructs the Response implementation to close and do the |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2563 * necessary clean up procedures. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2564 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2565 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2566 public void close() { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2567 // feed all rows to the garbage collector |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2568 for (int i = 0; i < data.length; i++) |
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2569 data[i] = null; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2570 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2571 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2572 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2573 * Retrieves the required row. Warning: if the requested rows |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2574 * is out of bounds, an IndexOutOfBoundsException will be |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2575 * thrown. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2576 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2577 * @param line the row to retrieve |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2578 * @return the requested row as String |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2579 */ |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2580 String getRow(final int line) { |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2581 if (forwardOnly) { |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2582 final String ret = data[line]; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2583 data[line] = null; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2584 return ret; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2585 } else { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2586 return data[line]; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2587 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2588 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2589 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2590 // }}} |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2591 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2592 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2593 * The UpdateResponse represents an update statement response. It |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2594 * is issued on an UPDATE, INSERT or DELETE SQL statement. This |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2595 * response keeps a count field that represents the affected rows |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2596 * and a field that contains the last inserted auto-generated ID, or |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2597 * -1 if not applicable.<br /> |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2598 * <tt>&2 0 -1</tt> |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2599 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2600 // {{{ UpdateResponse class implementation |
296
c5efd6e661e5
Add "final" keyword to classes, method arguments and local variables where possible.`
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
295
diff
changeset
|
2601 final static class UpdateResponse implements Response { |
378
02f353f62abe
Adjust UpdateResponse to allow for large updates (long instead of int).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
377
diff
changeset
|
2602 public final long count; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2603 public final String lastid; |
77
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
2604 |
378
02f353f62abe
Adjust UpdateResponse to allow for large updates (long instead of int).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
377
diff
changeset
|
2605 public UpdateResponse(final long cnt, final String id) { |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2606 // fill the blank finals |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2607 this.count = cnt; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2608 this.lastid = id; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2609 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2610 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2611 @Override |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2612 public String addLine(final String line, final int linetype) { |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2613 return "Header lines are not supported for an UpdateResponse"; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2614 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2615 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2616 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2617 public boolean wantsMore() { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2618 return false; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2619 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2620 |
324
0b01771d5f8a
Method Response.complete() is never used or needed. Disabled the code from the interface and its implementations.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
300
diff
changeset
|
2621 /* MvD: disabled not used/needed code |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2622 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2623 public void complete() { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2624 // empty, because there is nothing to check |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2625 } |
324
0b01771d5f8a
Method Response.complete() is never used or needed. Disabled the code from the interface and its implementations.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
300
diff
changeset
|
2626 */ |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2627 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2628 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2629 public void close() { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2630 // nothing to do here... |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2631 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2632 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2633 // }}} |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2634 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2635 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2636 * The SchemaResponse represents an schema modification response. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2637 * It is issued on statements like CREATE, DROP or ALTER TABLE. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2638 * This response keeps a field that represents the success state, as |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2639 * defined by JDBC, which is currently in MonetDB's case alwats |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2640 * SUCCESS_NO_INFO. Note that this state is not sent by the |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2641 * server.<br /> |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2642 * <tt>&3</tt> |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2643 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2644 // {{{ SchemaResponse class implementation |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2645 class SchemaResponse implements Response { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2646 public final int state = Statement.SUCCESS_NO_INFO; |
77
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
2647 |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2648 @Override |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2649 public String addLine(final String line, final int linetype) { |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2650 return "Header lines are not supported for a SchemaResponse"; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2651 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2652 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2653 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2654 public boolean wantsMore() { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2655 return false; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2656 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2657 |
324
0b01771d5f8a
Method Response.complete() is never used or needed. Disabled the code from the interface and its implementations.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
300
diff
changeset
|
2658 /* MvD: disabled not used/needed code |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2659 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2660 public void complete() { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2661 // empty, because there is nothing to check |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2662 } |
324
0b01771d5f8a
Method Response.complete() is never used or needed. Disabled the code from the interface and its implementations.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
300
diff
changeset
|
2663 */ |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2664 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2665 @Override |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2666 public void close() { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2667 // nothing to do here... |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2668 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2669 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2670 // }}} |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2671 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2672 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2673 * The AutoCommitResponse represents a transaction message. It |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2674 * stores (a change in) the server side auto commit mode.<br /> |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2675 * <tt>&4 (t|f)</tt> |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2676 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2677 // {{{ AutoCommitResponse class implementation |
296
c5efd6e661e5
Add "final" keyword to classes, method arguments and local variables where possible.`
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
295
diff
changeset
|
2678 private final class AutoCommitResponse extends SchemaResponse { |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2679 public final boolean autocommit; |
77
83aee4f60649
Added private method sendTransactionCommand(String); to reduce duplicate code in 6 methods.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
47
diff
changeset
|
2680 |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2681 public AutoCommitResponse(final boolean ac) { |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2682 // fill the blank final |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2683 this.autocommit = ac; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2684 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2685 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2686 // }}} |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2687 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2688 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2689 * A list of Response objects. Responses are added to this list. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2690 * Methods of this class are not synchronized. This is left as |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2691 * responsibility to the caller to prevent concurrent access. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2692 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2693 // {{{ ResponseList class implementation |
296
c5efd6e661e5
Add "final" keyword to classes, method arguments and local variables where possible.`
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
295
diff
changeset
|
2694 final class ResponseList { |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2695 /** The cache size (number of rows in a DataBlockResponse object) */ |
186
4767b005a531
Making variables private where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
184
diff
changeset
|
2696 private final int cachesize; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2697 /** The maximum number of results for this query */ |
376
ffdc7b0e102d
Updated JDBC driver to comply with JDBC 4.2 interface now we compile for Java 8. This includes:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
370
diff
changeset
|
2698 private final long maxrows; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2699 /** The ResultSet type to produce */ |
186
4767b005a531
Making variables private where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
184
diff
changeset
|
2700 private final int rstype; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2701 /** The ResultSet concurrency to produce */ |
186
4767b005a531
Making variables private where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
184
diff
changeset
|
2702 private final int rsconcur; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2703 /** The sequence number of this ResponseList */ |
186
4767b005a531
Making variables private where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
184
diff
changeset
|
2704 private final int seqnr; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2705 /** A list of the Responses associated with the query, |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2706 * in the right order */ |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2707 private final ArrayList<Response> responses; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2708 /** A map of ResultSetResponses, used for additional |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2709 * DataBlockResponse mapping */ |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2710 private HashMap<Integer, ResultSetResponse> rsresponses; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2711 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2712 /** The current header returned by getNextResponse() */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2713 private int curResponse; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2714 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2715 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2716 * Main constructor. The query argument can either be a String |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2717 * or List. An SQLException is thrown if another object |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2718 * instance is supplied. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2719 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2720 * @param cachesize overall cachesize to use |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2721 * @param maxrows maximum number of rows to allow in the set |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2722 * @param rstype the type of result sets to produce |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2723 * @param rsconcur the concurrency of result sets to produce |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2724 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2725 ResponseList( |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2726 final int cachesize, |
376
ffdc7b0e102d
Updated JDBC driver to comply with JDBC 4.2 interface now we compile for Java 8. This includes:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
370
diff
changeset
|
2727 final long maxrows, |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2728 final int rstype, |
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2729 final int rsconcur |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2730 ) throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2731 this.cachesize = cachesize; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2732 this.maxrows = maxrows; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2733 this.rstype = rstype; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2734 this.rsconcur = rsconcur; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2735 responses = new ArrayList<Response>(); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2736 curResponse = -1; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2737 seqnr = MonetConnection.seqCounter++; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2738 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2739 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2740 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2741 * Retrieves the next available response, or null if there are |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2742 * no more responses. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2743 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2744 * @return the next Response available or null |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2745 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2746 Response getNextResponse() throws SQLException { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2747 if (rstype == ResultSet.TYPE_FORWARD_ONLY) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2748 // free resources if we're running forward only |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2749 if (curResponse >= 0 && curResponse < responses.size()) { |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2750 final Response tmp = responses.get(curResponse); |
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
|
2751 if (tmp != null) |
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
|
2752 tmp.close(); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2753 responses.set(curResponse, null); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2754 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2755 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2756 curResponse++; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2757 if (curResponse >= responses.size()) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2758 // ResponseList is obviously completed so, there are no |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2759 // more responses |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2760 return null; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2761 } else { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2762 // return this response |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2763 return responses.get(curResponse); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2764 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2765 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2766 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2767 /** |
288
f412032e3b43
Correcting typo
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
286
diff
changeset
|
2768 * Closes the Response at index i, if not null. |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2769 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2770 * @param i the index position of the header to close |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2771 */ |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2772 void closeResponse(final int i) { |
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
|
2773 if (i < 0 || i >= responses.size()) |
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
|
2774 return; |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2775 final Response tmp = responses.set(i, null); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2776 if (tmp != null) |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2777 tmp.close(); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2778 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2779 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2780 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2781 * Closes the current response. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2782 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2783 void closeCurrentResponse() { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2784 closeResponse(curResponse); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2785 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2786 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2787 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2788 * Closes the current and previous responses. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2789 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2790 void closeCurOldResponses() { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2791 for (int i = curResponse; i >= 0; i--) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2792 closeResponse(i); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2793 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2794 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2795 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2796 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2797 * Closes this ResponseList by closing all the Responses in this |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2798 * ResponseList. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2799 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2800 void close() { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2801 for (int i = 0; i < responses.size(); i++) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2802 closeResponse(i); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2803 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2804 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2805 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2806 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2807 * Returns whether this ResponseList has still unclosed |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2808 * Responses. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2809 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2810 boolean hasUnclosedResponses() { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2811 for (Response r : responses) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2812 if (r != null) |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2813 return true; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2814 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2815 return false; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2816 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2817 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2818 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2819 * Executes the query contained in this ResponseList, and |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2820 * stores the Responses resulting from this query in this |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2821 * ResponseList. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2822 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2823 * @throws SQLException if a database error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2824 */ |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2825 void processQuery(final String query) throws SQLException { |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2826 executeQuery(queryTempl, query); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2827 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2828 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2829 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2830 * Internal executor of queries. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2831 * |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2832 * @param templ the template to fill in |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2833 * @param the query to execute |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2834 * @throws SQLException if a database error occurs |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2835 */ |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2836 @SuppressWarnings("fallthrough") |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2837 void executeQuery(final String[] templ, final String query) |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2838 throws SQLException |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2839 { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2840 String error = null; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2841 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2842 try { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2843 synchronized (server) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2844 // make sure we're ready to send query; read data till we |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2845 // have the prompt it is possible (and most likely) that we |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2846 // already have the prompt and do not have to skip any |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2847 // lines. Ignore errors from previous result sets. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2848 in.waitForPrompt(); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2849 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2850 // {{{ set reply size |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2851 /** |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2852 * Change the reply size of the server. If the given |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2853 * value is the same as the current value known to use, |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2854 * then ignore this call. If it is set to 0 we get a |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2855 * prompt after the server sent it's header. |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2856 */ |
178
dd12348c41cf
Improvement: only extend typeMap when the property was set to true.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
175
diff
changeset
|
2857 int size = (cachesize == 0 ? DEF_FETCHSIZE : cachesize); |
dd12348c41cf
Improvement: only extend typeMap when the property was set to true.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
175
diff
changeset
|
2858 if (maxrows > 0 && maxrows < size) |
376
ffdc7b0e102d
Updated JDBC driver to comply with JDBC 4.2 interface now we compile for Java 8. This includes:
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
370
diff
changeset
|
2859 size = (int)maxrows; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2860 // don't do work if it's not needed |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2861 if (lang == LANG_SQL && size != curReplySize && templ != commandTempl) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2862 sendControlCommand("reply_size " + size); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2863 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2864 // store the reply size after a successful change |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2865 curReplySize = size; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2866 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2867 // }}} set reply size |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2868 |
285
637899bda602
Removed SendThread class and its usage from MonetConnection.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
284
diff
changeset
|
2869 // send query to the server |
637899bda602
Removed SendThread class and its usage from MonetConnection.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
284
diff
changeset
|
2870 out.writeLine( (templ[0] == null ? "" : templ[0]) + query + (templ[1] == null ? "" : templ[1]) ); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2871 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2872 // go for new results |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2873 String tmpLine = in.readLine(); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2874 int linetype = in.getLineType(); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2875 Response res = null; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2876 while (linetype != BufferedMCLReader.PROMPT) { |
284
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2877 // each response should start with a start of header (or error) |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2878 switch (linetype) { |
284
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2879 case BufferedMCLReader.SOHEADER: |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2880 // make the response object, and fill it |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2881 try { |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2882 switch (sohp.parse(tmpLine)) { |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2883 case StartOfHeaderParser.Q_PARSE: |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2884 throw new MCLParseException("Q_PARSE header not allowed here", 1); |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2885 case StartOfHeaderParser.Q_TABLE: |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2886 case StartOfHeaderParser.Q_PREPARE: { |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2887 final int id = sohp.getNextAsInt(); |
377
8a813f5cef1b
Extend StartOfHeaderParser with method getNextAsLong() and change type of tuplecount to long.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
376
diff
changeset
|
2888 long tuplecount = sohp.getNextAsLong(); |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2889 final int columncount = sohp.getNextAsInt(); |
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2890 final int rowcount = sohp.getNextAsInt(); |
284
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2891 // enforce the maxrows setting |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2892 if (maxrows != 0 && tuplecount > maxrows) |
377
8a813f5cef1b
Extend StartOfHeaderParser with method getNextAsLong() and change type of tuplecount to long.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
376
diff
changeset
|
2893 tuplecount = maxrows; |
284
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2894 res = new ResultSetResponse(id, tuplecount, columncount, rowcount, this, seqnr); |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2895 // only add this resultset to the hashmap if it can possibly have an additional datablock |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2896 if (rowcount < tuplecount) { |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2897 if (rsresponses == null) |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2898 rsresponses = new HashMap<Integer, ResultSetResponse>(); |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2899 rsresponses.put(Integer.valueOf(id), (ResultSetResponse) res); |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2900 } |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2901 } break; |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2902 case StartOfHeaderParser.Q_UPDATE: |
378
02f353f62abe
Adjust UpdateResponse to allow for large updates (long instead of int).
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
377
diff
changeset
|
2903 res = new UpdateResponse(sohp.getNextAsLong(), // count |
284
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2904 sohp.getNextAsString() // key-id |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2905 ); |
284
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2906 break; |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2907 case StartOfHeaderParser.Q_SCHEMA: |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2908 res = new SchemaResponse(); |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2909 break; |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2910 case StartOfHeaderParser.Q_TRANS: |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2911 final boolean ac = sohp.getNextAsString().equals("t") ? true : false; |
284
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2912 if (autoCommit && ac) { |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2913 addWarning("Server enabled auto commit mode " + |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2914 "while local state already was auto commit.", "01M11"); |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2915 } |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2916 autoCommit = ac; |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2917 res = new AutoCommitResponse(ac); |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2918 break; |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2919 case StartOfHeaderParser.Q_BLOCK: { |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2920 // a new block of results for a response... |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2921 final int id = sohp.getNextAsInt(); |
284
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2922 sohp.getNextAsInt(); // columncount |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2923 final int rowcount = sohp.getNextAsInt(); |
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2924 final int offset = sohp.getNextAsInt(); |
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2925 final ResultSetResponse t = (rsresponses != null) ? rsresponses.get(Integer.valueOf(id)) : null; |
284
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2926 if (t == null) { |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2927 error = "M0M12!no ResultSetResponse with id " + id + " found"; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2928 break; |
284
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2929 } |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
2930 final DataBlockResponse r = new DataBlockResponse(rowcount, t.getRSType() == ResultSet.TYPE_FORWARD_ONLY); |
284
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2931 t.addDataBlockResponse(offset, r); |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2932 res = r; |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2933 } break; |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2934 } // end of switch (sohp.parse(tmpLine)) |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2935 } catch (MCLParseException e) { |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2936 error = "M0M10!error while parsing start of header:\n" + |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2937 e.getMessage() + |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2938 " found: '" + tmpLine.charAt(e.getErrorOffset()) + "'" + |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2939 " in: \"" + tmpLine + "\"" + |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2940 " at pos: " + e.getErrorOffset(); |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2941 // flush all the rest |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2942 in.waitForPrompt(); |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2943 linetype = in.getLineType(); |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2944 break; |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2945 } |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2946 |
284
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2947 // immediately handle errors after parsing the header (res may be null) |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2948 if (error != null) { |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2949 in.waitForPrompt(); |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2950 linetype = in.getLineType(); |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2951 break; |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2952 } |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2953 |
284
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2954 // here we have a res object, which we can start filling |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2955 while (res.wantsMore()) { |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2956 error = res.addLine(in.readLine(), in.getLineType()); |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2957 if (error != null) { |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2958 // right, some protocol violation, |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2959 // skip the rest of the result |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2960 error = "M0M10!" + error; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2961 in.waitForPrompt(); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2962 linetype = in.getLineType(); |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2963 break; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2964 } |
284
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2965 } |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2966 if (error != null) |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2967 break; |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2968 |
288
f412032e3b43
Correcting typo
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
286
diff
changeset
|
2969 // it is of no use to store DataBlockResponses, you never want to |
284
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2970 // retrieve them directly anyway |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2971 if (!(res instanceof DataBlockResponse)) |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2972 responses.add(res); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2973 |
284
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2974 // read the next line (can be prompt, new result, error, etc.) |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2975 // before we start the loop over |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2976 tmpLine = in.readLine(); |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2977 linetype = in.getLineType(); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2978 break; |
284
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2979 case BufferedMCLReader.INFO: |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2980 addWarning(tmpLine.substring(1), "01000"); |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2981 // read the next line (can be prompt, new result, error, etc.) |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2982 // before we start the loop over |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2983 tmpLine = in.readLine(); |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2984 linetype = in.getLineType(); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
2985 break; |
284
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2986 default: // Yeah... in Java this is correct! |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2987 // we have something we don't expect/understand, let's make it an error message |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2988 tmpLine = "!M0M10!protocol violation, unexpected line: " + tmpLine; |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2989 // don't break; fall through... |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2990 case BufferedMCLReader.ERROR: |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2991 // read everything till the prompt (should be |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2992 // error) we don't know if we ignore some |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2993 // garbage here... but the log should reveal that |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2994 error = in.waitForPrompt(); |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2995 linetype = in.getLineType(); |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2996 if (error != null) { |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2997 error = tmpLine.substring(1) + "\n" + error; |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2998 } else { |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
2999 error = tmpLine.substring(1); |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
3000 } |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
3001 break; |
284
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
3002 } // end of switch (linetype) |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
3003 } // end of while (linetype != BufferedMCLReader.PROMPT) |
e5b99c929a2d
Improve setSchema(String schema) by checking also on empty name.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
278
diff
changeset
|
3004 } // end of synchronized (server) |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
3005 |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
3006 if (error != null) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
3007 SQLException ret = null; |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
3008 final String[] errors = error.split("\n"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
3009 for (int i = 0; i < errors.length; i++) { |
295
003ae6d881db
Add "final" keyword to method arguments and local variables where possible.
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
292
diff
changeset
|
3010 final SQLException newErr; |
144
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
136
diff
changeset
|
3011 if (errors[i].length() >= 6) { |
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
136
diff
changeset
|
3012 newErr = new SQLException(errors[i].substring(6), errors[i].substring(0, 5)); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
3013 } else { |
144
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
136
diff
changeset
|
3014 newErr = new SQLNonTransientConnectionException(errors[i], "08000"); |
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
136
diff
changeset
|
3015 } |
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
136
diff
changeset
|
3016 if (ret == null) { |
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
136
diff
changeset
|
3017 ret = newErr; |
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
136
diff
changeset
|
3018 } else { |
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
136
diff
changeset
|
3019 ret.setNextException(newErr); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
3020 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
3021 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
3022 throw ret; |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
3023 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
3024 } catch (SocketTimeoutException e) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
3025 close(); // JDBC 4.1 semantics, abort() |
144
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
136
diff
changeset
|
3026 throw new SQLNonTransientConnectionException("connection timed out", "08M33"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
3027 } catch (IOException e) { |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
3028 closed = true; |
144
d6abd1ffffbb
Use SQLNonTransientConnectionException instead of SQLException where applicable (SQLState starts with 08)
Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
parents:
136
diff
changeset
|
3029 throw new SQLNonTransientConnectionException(e.getMessage() + " (mserver5 still alive?)", "08006"); |
0
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
3030 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
3031 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
3032 } |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
3033 // }}} |
a5a898f6886c
Copy of MonetDB java directory changeset e6e32756ad31.
Sjoerd Mullender <sjoerd@acm.org>
parents:
diff
changeset
|
3034 } |