Mercurial > hg > monetdb-java
comparison src/main/java/org/monetdb/jdbc/MonetConnection.java @ 414:1e278695fe54
Small improvements: adding some final keywords, removing unnecesary initialisations, improve comments.
author | Martin van Dinther <martin.van.dinther@monetdbsolutions.com> |
---|---|
date | Thu, 14 Jan 2021 22:44:56 +0100 (2021-01-14) |
parents | 5540793628d6 |
children | b3c876a0d61f |
comparison
equal
deleted
inserted
replaced
413:f0dfd2003aff | 414:1e278695fe54 |
---|---|
90 private final BufferedMCLReader in; | 90 private final BufferedMCLReader in; |
91 /** The Writer to the server */ | 91 /** The Writer to the server */ |
92 private final BufferedMCLWriter out; | 92 private final BufferedMCLWriter out; |
93 | 93 |
94 /** A StartOfHeaderParser declared for reuse. */ | 94 /** A StartOfHeaderParser declared for reuse. */ |
95 private StartOfHeaderParser sohp = new StartOfHeaderParser(); | 95 private final StartOfHeaderParser sohp = new StartOfHeaderParser(); |
96 | 96 |
97 /** Whether this Connection is closed (and cannot be used anymore) */ | 97 /** Whether this Connection is closed (and cannot be used anymore) */ |
98 private boolean closed; | 98 private boolean closed; |
99 | 99 |
100 /** Whether this Connection is in autocommit mode */ | 100 /** Whether this Connection is in autocommit mode */ |
113 }; | 113 }; |
114 | 114 |
115 // See javadoc for documentation about WeakHashMap if you don't know what | 115 // See javadoc for documentation about WeakHashMap if you don't know what |
116 // it does !!!NOW!!! (only when you deal with it of course) | 116 // it does !!!NOW!!! (only when you deal with it of course) |
117 /** A Map containing all (active) Statements created from this Connection */ | 117 /** A Map containing all (active) Statements created from this Connection */ |
118 private WeakHashMap<Statement,?> statements = new WeakHashMap<Statement, Object>(); | 118 private final WeakHashMap<Statement,?> statements = new WeakHashMap<Statement, Object>(); |
119 | 119 |
120 /** The number of results we receive from the server at once */ | 120 /** The number of results we receive from the server at once */ |
121 private int curReplySize = -1; // the server by default uses -1 (all) | 121 private int curReplySize = -1; // the server by default uses -1 (all) |
122 | 122 |
123 /** A template to apply to each query (like pre and post fixes), filled in constructor */ | 123 /** A template to apply to each query (like pre and post fixes), filled in constructor */ |
135 private static final int LANG_UNKNOWN = -1; | 135 private static final int LANG_UNKNOWN = -1; |
136 /** The language which is used */ | 136 /** The language which is used */ |
137 private final int lang; | 137 private final int lang; |
138 | 138 |
139 /** Whether or not BLOB is mapped to Types.VARBINARY instead of Types.BLOB within this connection */ | 139 /** Whether or not BLOB is mapped to Types.VARBINARY instead of Types.BLOB within this connection */ |
140 private boolean treatBlobAsVarBinary = true; | 140 private boolean treatBlobAsVarBinary = true; // turned on by default for optimal performance (from JDBC Driver release 2.30 onwards) |
141 /** Whether or not CLOB is mapped to Types.VARCHAR instead of Types.CLOB within this connection */ | 141 /** Whether or not CLOB is mapped to Types.VARCHAR instead of Types.CLOB within this connection */ |
142 private boolean treatClobAsVarChar = true; | 142 private boolean treatClobAsVarChar = true; // turned on by default for optimal performance (from JDBC Driver release 2.30 onwards) |
143 | 143 |
144 /** The last set query timeout on the server as used by Statement, PreparedStatement and CallableStatement */ | 144 /** The last set query timeout on the server as used by Statement, PreparedStatement and CallableStatement */ |
145 protected int lastSetQueryTimeout; // 0 means no timeout, which is the default on the server | 145 protected int lastSetQueryTimeout; // 0 means no timeout, which is the default on the server |
146 | 146 |
147 | 147 |
883 * a concurrency level of CONCUR_READ_ONLY. The holdability of the created result sets can be determined by calling getHoldability(). | 883 * a concurrency level of CONCUR_READ_ONLY. The holdability of the created result sets can be determined by calling getHoldability(). |
884 * | 884 * |
885 * @param sql - an SQL statement that may contain one or more '?' IN parameter placeholders | 885 * @param sql - an SQL statement that may contain one or more '?' IN parameter placeholders |
886 * @param columnIndexes - an array of column indexes indicating the columns that should be returned from the inserted row or rows | 886 * @param columnIndexes - an array of column indexes indicating the columns that should be returned from the inserted row or rows |
887 * @return a new PreparedStatement object, containing the pre-compiled statement, that is capable of | 887 * @return a new PreparedStatement object, containing the pre-compiled statement, that is capable of |
888 * returning the auto-generated keys designated by the given array of column indexes | 888 * returning the auto-generated keys designated by the given array of column indexes |
889 * @throws SQLException - if a database access error occurs or this method is called on a closed connection | 889 * @throws SQLException - if a database access error occurs or this method is called on a closed connection |
890 * @throws SQLFeatureNotSupportedException - if the JDBC driver does not support this method | 890 * @throws SQLFeatureNotSupportedException - if the JDBC driver does not support this method |
891 */ | 891 */ |
892 @Override | 892 @Override |
893 public PreparedStatement prepareStatement(final String sql, final int[] columnIndexes) throws SQLException { | 893 public PreparedStatement prepareStatement(final String sql, final int[] columnIndexes) throws SQLException { |
912 * a concurrency level of CONCUR_READ_ONLY. The holdability of the created result sets can be determined by calling getHoldability(). | 912 * a concurrency level of CONCUR_READ_ONLY. The holdability of the created result sets can be determined by calling getHoldability(). |
913 * | 913 * |
914 * @param sql - an SQL statement that may contain one or more '?' IN parameter placeholders | 914 * @param sql - an SQL statement that may contain one or more '?' IN parameter placeholders |
915 * @param columnNames - an array of column names indicating the columns that should be returned from the inserted row or rows | 915 * @param columnNames - an array of column names indicating the columns that should be returned from the inserted row or rows |
916 * @return a new PreparedStatement object, containing the pre-compiled statement, that is capable of | 916 * @return a new PreparedStatement object, containing the pre-compiled statement, that is capable of |
917 * returning the auto-generated keys designated by the given array of column names | 917 * returning the auto-generated keys designated by the given array of column names |
918 * @throws SQLException - if a database access error occurs or this method is called on a closed connection | 918 * @throws SQLException - if a database access error occurs or this method is called on a closed connection |
919 * @throws SQLFeatureNotSupportedException - if the JDBC driver does not support this method | 919 * @throws SQLFeatureNotSupportedException - if the JDBC driver does not support this method |
920 */ | 920 */ |
921 @Override | 921 @Override |
922 public PreparedStatement prepareStatement(final String sql, final String[] columnNames) throws SQLException { | 922 public PreparedStatement prepareStatement(final String sql, final String[] columnNames) throws SQLException { |
1324 closeResultsetStatement(rs, stmt); | 1324 closeResultsetStatement(rs, stmt); |
1325 /* when changed, reset the original server timeout value on the server */ | 1325 /* when changed, reset the original server timeout value on the server */ |
1326 if (timeout > 0 && original_timeout != this.lastSetQueryTimeout) { | 1326 if (timeout > 0 && original_timeout != this.lastSetQueryTimeout) { |
1327 this.lastSetQueryTimeout = original_timeout; | 1327 this.lastSetQueryTimeout = original_timeout; |
1328 try { | 1328 try { |
1329 /* we have to set in the server explicitly, because the test 'queryTimeout != connection.lastSetQueryTimeout' | 1329 /* we have to set in the server explicitly, because the test 'queryTimeout != connection.lastSetQueryTimeout' |
1330 on MonetStatement.internalExecute(sql) won't pass and the server won't be set back */ | 1330 on MonetStatement.internalExecute(sql) won't pass and the server won't be set back */ |
1331 setQueryTimeout(original_timeout); | 1331 setQueryTimeout(original_timeout); |
1332 } catch (SQLException se) { | 1332 } catch (SQLException se) { |
1333 /* ignore stmt errors/exceptions, we are only testing if the connection is still alive and usable */ | 1333 /* ignore stmt errors/exceptions, we are only testing if the connection is still alive and usable */ |
1334 } | 1334 } |