Mercurial > hg > monetdb-java
changeset 709:bdeabbd46ec6
Resolve javac and javadoc warnings when compiled with JDK19.
author | Martin van Dinther <martin.van.dinther@monetdbsolutions.com> |
---|---|
date | Thu, 15 Dec 2022 19:31:53 +0100 (2022-12-15) |
parents | 5022a57f9d97 |
children | 437e51b4c169 |
files | src/main/java/org/monetdb/client/JdbcClient.java src/main/java/org/monetdb/jdbc/MonetCallableStatement.java src/main/java/org/monetdb/jdbc/MonetConnection.java src/main/java/org/monetdb/jdbc/MonetDatabaseMetaData.java src/main/java/org/monetdb/jdbc/MonetDriver.java.in src/main/java/org/monetdb/jdbc/MonetPreparedStatement.java src/main/java/org/monetdb/jdbc/MonetResultSet.java src/main/java/org/monetdb/jdbc/MonetStatement.java src/main/java/org/monetdb/mcl/io/BufferedMCLReader.java src/main/java/org/monetdb/mcl/net/MapiSocket.java src/main/java/org/monetdb/mcl/parser/HeaderLineParser.java src/main/java/org/monetdb/util/SQLRestore.java |
diffstat | 12 files changed, 149 insertions(+), 44 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/org/monetdb/client/JdbcClient.java +++ b/src/main/java/org/monetdb/client/JdbcClient.java @@ -847,6 +847,9 @@ public class JdbcClient { /* cannot (yet * or describe a specific table or view by printing the CREATE DDL statement * See also showCommands() * These commands are almost the same as in mclient program + * + * @param dcommand the command starting with \d + * @param scolonterm whether a ';' makes this query part complete */ private static void processDescribeCmd(final String dcommand, final boolean scolonterm) {
--- a/src/main/java/org/monetdb/jdbc/MonetCallableStatement.java +++ b/src/main/java/org/monetdb/jdbc/MonetCallableStatement.java @@ -79,6 +79,7 @@ public final class MonetCallableStatemen * @param connection the connection that created this Statement * @param resultSetType type of {@link java.sql.ResultSet} to produce * @param resultSetConcurrency concurrency of ResultSet to produce + * @param resultSetHoldability holdability of ResultSet to produce * @param callQuery - an SQL CALL statement that may contain one or more '?' parameter placeholders. * Typically this statement is specified using JDBC call escape syntax: * { call procedure_name [(?,?, ...)] } @@ -107,6 +108,9 @@ public final class MonetCallableStatemen /** parse call query string on * { [?=] call <procedure-name> [(<arg1>,<arg2>, ...)] } * and remove the JDBC escapes pairs: { and } + * + * @param query the SQL call statement + * @return query without the escape characters: { and } */ final private static String removeEscapes(final String query) { if (query == null) @@ -147,9 +151,13 @@ public final class MonetCallableStatemen return buf.toString(); } - /** utility method to convert a parameter name to an int (which represents the parameter index) - * this will only succeed for strings like: "1", "2", "3", etc - * throws SQLException if it cannot convert the string to an integer number + /** + * utility method to convert a parameter name to an int (which represents the parameter index) + * this will only succeed for strings like: "1", "2", "3", etc + * + * @param parameterName the name (a number value) of the parameter + * @return the converted index number + * @throws SQLException if it cannot convert the string to an integer number */ final private int nameToIndex(final String parameterName) throws SQLException { if (parameterName == null)
--- a/src/main/java/org/monetdb/jdbc/MonetConnection.java +++ b/src/main/java/org/monetdb/jdbc/MonetConnection.java @@ -1708,7 +1708,9 @@ public class MonetConnection } /** - * @return the currently registerered {@link UploadHandler}, or null + * Get the currently registerered {@link UploadHandler}, or null + * + * @return the currently registerered UploadHandler, or null */ public UploadHandler getUploadHandler() { return uploadHandler; @@ -1724,13 +1726,21 @@ public class MonetConnection } /** - * @return the currently registerered {@link DownloadHandler} handler, or null + * Get the currently registerered {@link DownloadHandler} handler, or null + * + * @return the currently registerered DownloadHandler handler, or null */ public DownloadHandler getDownloadHandler() { return downloadHandler; } - public void setTimezone(int offsetSeconds) throws SQLException { + /** + * Local helper method to set the time zone for this connection + * + * @param offsetSeconds Time Zone offset in seconds, can be negative or zero + * @throws SQLException if an IO exception or a database error occurs + */ + private void setTimezone(int offsetSeconds) throws SQLException { final StringBuilder tz = new StringBuilder(64); tz.append("SET TIME ZONE INTERVAL '"); int offsetMinutes = offsetSeconds / 60; @@ -1752,8 +1762,10 @@ public class MonetConnection } /** - * Local helper method to test whether the Connection object is closed - * When closed it throws an SQLException + * Local helper method to check whether the Connection object is closed + * and throw an SQLExecption if it is closed. + * + * @throws SQLException if this connection is closed */ private void checkNotClosed() throws SQLException { if (closed) @@ -1761,8 +1773,12 @@ public class MonetConnection } /** - * Utility method to call sys.setquerytimeout(int); procedure on the connected server. + * Utility method to call sys.setquerytimeout(int); procedure on the connected server + * or sys.settimeout(int); procedure on older servers which do not support the new procedure. * It is called from: MonetConnection.isValid() and MonetStatement.internalExecute() + * + * @param seconds the time out time in seconds + * @throws SQLException if an IO exception or a database error occurs */ void setQueryTimeout(final int seconds) throws SQLException { if (seconds < 0) @@ -1774,7 +1790,8 @@ public class MonetConnection final String callstmt; final int msecs = (seconds <= 2147483) ? seconds * 1000 : seconds; // prevent overflow of int - // as of release Jun2020 (11.37.7) the function sys.settimeout(msecs bigint) is deprecated and replaced by new sys.setquerytimeout(msecs int) + // as of release Jun2020 (11.37.7) the function sys.settimeout(msecs bigint) + // is deprecated and replaced by new sys.setquerytimeout(msecs int) if ((getDatabaseMajorVersion() == 11) && (getDatabaseMinorVersion() < 37)) callstmt = "CALL sys.\"settimeout\"(" + msecs + ")"; else @@ -1793,28 +1810,31 @@ public class MonetConnection } /** - * @return whether the JDBC BLOB type should be mapped to VARBINARY type. * This allows generic JDBC programs to fetch Blob data via getBytes() * instead of getBlob() and Blob.getBinaryStream() to reduce overhead. * It is called from: MonetResultSet and MonetPreparedStatement + * + * @return whether the JDBC BLOB type should be mapped to VARBINARY type. */ boolean mapBlobAsVarBinary() { return treatBlobAsVarBinary; } /** - * @return whether the JDBC CLOB type should be mapped to VARCHAR type. * This allows generic JDBC programs to fetch Clob data via getString() * instead of getClob() and Clob.getCharacterStream() to reduce overhead. * It is called from: MonetResultSet and MonetPreparedStatement + * + * @return whether the JDBC CLOB type should be mapped to VARCHAR type. */ boolean mapClobAsVarChar() { return treatClobAsVarChar; } /** + * It is called from: getURL()in MonetDatabaseMetaData + * * @return the MonetDB JDBC Connection URL (without user name and password). - * It is called from: getURL()in MonetDatabaseMetaData */ String getJDBCURL() { final StringBuilder sb = new StringBuilder(128); @@ -1827,8 +1847,11 @@ public class MonetConnection } /** - * Utility method to validate if property name is supported. - * If not supported a warning is added to this Connection. + * Utility method to check if connection property name is supported. + * If it is not supported a warning is added to this Connection. + * + * @param name the connection property name to check + * @param context the method name from where this is called * @return valid true or false */ private boolean checkValidProperty(String name, String context) { @@ -1865,6 +1888,8 @@ public class MonetConnection * We fetch the env values of: current_user, monet_version, max_clients and raw_strings. * We cache them such that we do not need to query the server again and again. * Note: raw_strings is available in sys.env() result set since release Jun2020 (11.37) + * + * @throws SQLException if execution of query failed */ private synchronized void getEnvValues() throws SQLException { Statement st = null; @@ -1909,8 +1934,11 @@ public class MonetConnection } /** - * @return the current User Name. + * Get user login name from the server. * It is called from: MonetDatabaseMetaData + * + * @return the current User Name for this comnection + * @throws SQLException if fetching user name failed */ String getUserName() throws SQLException { if (env_current_user == null) @@ -1919,9 +1947,12 @@ public class MonetConnection } /** - * @return the maximum number of active connections possible at one time; - * a result of zero means that there is no limit or the limit is not known + * Get the maximum number of allowed connections from the server. * It is called from: MonetDatabaseMetaData + * A result of zero means that there is no limit or the limit is not known + * + * @return the maximum number of active connections possible at one time + * @throws SQLException if fetching maximum connections failed */ int getMaxConnections() throws SQLException { if (maxConnections == 0) @@ -1930,11 +1961,14 @@ public class MonetConnection } /** - * @return whether the server is started with raw_strings processing enabled. + * Get whether the server is started with raw_strings turned on. * By default this is false (so C-style strings processing is used). * When a server is started with option: --set raw_strings=true * then this will return true, else false. * This startup option is supported only by servers since Jun2020 (11.37) onwards. + * + * @return whether the server is started with raw_strings processing enabled. + * @throws SQLException if fetching raw_strings setting failed */ boolean inRawStringsMode() throws SQLException { if (env_raw_strings == null) { @@ -1953,8 +1987,11 @@ public class MonetConnection } /** + * Get the product version of the connected MonetDB Database Server. + * It is called from: MonetDatabaseMetaData + * * @return the MonetDB Database Server version string. - * It is called from: MonetDatabaseMetaData + * @throws SQLException if fetching MonetDB server version string failed */ String getDatabaseProductVersion() throws SQLException { if (env_monet_version == null) @@ -1967,9 +2004,12 @@ public class MonetConnection private int databaseMajorVersion; /** - * @return the MonetDB Database Server major version number. + * Get the major product version of the connected MonetDB Database Server. * The number is extracted from the env_monet_version the first time and cached for next calls. * It is called from: MonetDatabaseMetaData and MonetConnection + * + * @return the MonetDB Database Server major version number. + * @throws SQLException if fetching MonetDB server version string failed */ int getDatabaseMajorVersion() throws SQLException { if (databaseMajorVersion == 0) { @@ -1990,9 +2030,12 @@ public class MonetConnection private int databaseMinorVersion; /** - * @return the MonetDB Database Server minor version number. + * Get the minor product version of the connected MonetDB Database Server. * The number is extracted from the env_monet_version the first time and cached for next calls. * It is called from: MonetDatabaseMetaData and MonetConnection + * + * @return the MonetDB Database Server minor version number. + * @throws SQLException if fetching MonetDB server version string failed */ int getDatabaseMinorVersion() throws SQLException { if (databaseMinorVersion == 0) { @@ -2024,6 +2067,8 @@ public class MonetConnection * the system table sys.privilege_codes (which is new as of Jul2017 release). * The result is cached and reused, so that we only test the query once per connection. * This method is used by methods from MonetDatabaseMetaData. + * + * @return whether the system table sys.privilege_codes exist in the connected server. */ boolean privilege_codesTableExists() { if (!queriedPrivilege_codesTable) { @@ -2041,6 +2086,8 @@ public class MonetConnection * the system table sys.comments (which is new as of Mar2018 release). * The result is cached and reused, so that we only test the query once per connection. * This method is used by methods from MonetDatabaseMetaData. + * + * @return whether the system table sys.comments exist in the connected server. */ boolean commentsTableExists() { if (!queriedCommentsTable) { @@ -2178,12 +2225,13 @@ public class MonetConnection } /** - * Adds a warning to the pile of warnings this Connection object - * has. If there were no warnings (or clearWarnings was called) - * this warning will be the first, otherwise this warning will get + * Adds a warning to the pile of warnings this Connection object has. + * If there were no warnings (or clearWarnings was called) this + * warning will be the first, otherwise this warning will get * appended to the current warning. * * @param reason the warning message + * @param sqlstate the SQLState code (5 characters) */ private final void addWarning(final String reason, final String sqlstate) { final SQLWarning warng = new SQLWarning(reason, sqlstate); @@ -2344,7 +2392,6 @@ public class MonetConnection final int rowcount, final MonetConnection.ResponseList parent, final int seq) - throws SQLException { isSet = new boolean[5]; this.parent = parent; @@ -3023,9 +3070,7 @@ public class MonetConnection private int curResponse; /** - * Main constructor. The query argument can either be a String - * or List. An SQLException is thrown if another object - * instance is supplied. + * Main constructor. * * @param cachesize overall cachesize to use * @param maxrows maximum number of rows to allow in the set @@ -3036,8 +3081,8 @@ public class MonetConnection final int cachesize, final long maxrows, final int rstype, - final int rsconcur - ) throws SQLException { + final int rsconcur) + { this.cachesize = cachesize; this.maxrows = maxrows; this.rstype = rstype; @@ -3053,7 +3098,7 @@ public class MonetConnection * * @return the next Response available or null */ - Response getNextResponse() throws SQLException { + Response getNextResponse() { if (rstype == ResultSet.TYPE_FORWARD_ONLY) { // free resources if we're running forward only if (curResponse >= 0 && curResponse < responses.size()) { @@ -3116,6 +3161,7 @@ public class MonetConnection /** * Returns whether this ResponseList has still unclosed * Responses. + * @return whether there are unclosed Responses */ boolean hasUnclosedResponses() { for (Response r : responses) { @@ -3130,6 +3176,7 @@ public class MonetConnection * stores the Responses resulting from this query in this * ResponseList. * + * @param query the SQL query to execute * @throws SQLException if a database error occurs */ void processQuery(final String query) throws SQLException { @@ -3432,7 +3479,6 @@ public class MonetConnection * * An example implementation can be found at ../util/FileTransferHandler.java */ - public interface UploadHandler { /** * Called if the server sends a request to read file data. @@ -3554,6 +3600,7 @@ public class MonetConnection } /** + * Tell whether data or an error has been sent. * @return true if data or an error has been sent. */ public boolean hasBeenUsed() { @@ -3561,6 +3608,7 @@ public class MonetConnection } /** + * Get the error string. * @return the error that was sent, if any */ public String getError() { @@ -3736,6 +3784,7 @@ public class MonetConnection } /** + * Tell whether data has been received or an error has been sent. * @return true if data has been received or an error has been sent. */ public boolean hasBeenUsed() { @@ -3743,6 +3792,7 @@ public class MonetConnection } /** + * Get the error string. * @return the error that was sent, if any */ public String getError() {
--- a/src/main/java/org/monetdb/jdbc/MonetDatabaseMetaData.java +++ b/src/main/java/org/monetdb/jdbc/MonetDatabaseMetaData.java @@ -4209,6 +4209,10 @@ public final class MonetDatabaseMetaData * Internal utility method to create a Statement object, execute a query and return the ResulSet object which allows scrolling. * As the Statement object is created internally (the caller does not see it and thus can not close it), * we set it to close (and free server resources) when the ResultSet object is closed by the caller. + * + * @param query the SQL query to execute + * @return a scrollable ResulSet or null when query failed to be executed + * @throws SQLException if a database access error occurs */ private final ResultSet executeMetaDataQuery(final String query) throws SQLException { final Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
--- a/src/main/java/org/monetdb/jdbc/MonetDriver.java.in +++ b/src/main/java/org/monetdb/jdbc/MonetDriver.java.in @@ -302,12 +302,19 @@ public class MonetDriver implements Driv /** - * utility methods called by MonetDatabaseMetaData methods + * Get MonetDB JDBC Driver major version number + * method called by MonetDatabaseMetaData methods + * @return MonetDB JDBC Driver major version number */ static final int getDriverMajorVersion() { return @JDBC_MAJOR@; } + /** + * Get MonetDB JDBC Driver minor version number + * method called by MonetDatabaseMetaData methods + * @return MonetDB JDBC Driver minor version number + */ static final int getDriverMinorVersion() { return @JDBC_MINOR@; }
--- a/src/main/java/org/monetdb/jdbc/MonetPreparedStatement.java +++ b/src/main/java/org/monetdb/jdbc/MonetPreparedStatement.java @@ -314,6 +314,10 @@ public class MonetPreparedStatement /** * Returns the index (0..size-1) in the backing arrays for the given * resultset column number or an SQLException when not found + * + * @param colnr the output column number + * @return the internal column array index number + * @throws SQLException if column number can not be found in the internal array */ private final int getColumnIdx(final int colnr) throws SQLException { int curcol = 0; @@ -330,6 +334,10 @@ public class MonetPreparedStatement /** * Returns the index (0..size-1) in the backing arrays for the given * parameter number or an SQLException when not found + * + * @param paramnr the parameter number + * @return the internal column array index number + * @throws SQLException if parameter number can not be found in the internal array */ private final int getParamIdx(final int paramnr) throws SQLException { int curparam = 0;
--- a/src/main/java/org/monetdb/jdbc/MonetResultSet.java +++ b/src/main/java/org/monetdb/jdbc/MonetResultSet.java @@ -4054,6 +4054,7 @@ public class MonetResultSet * warning. * * @param reason the warning message + * @param sqlstate the SQLState code (5 characters) */ private void addWarning(final String reason, final String sqlstate) { SQLWarning warng = new SQLWarning(reason, sqlstate); @@ -4067,6 +4068,8 @@ public class MonetResultSet /** * Local helper method to test whether the ResultSet object is closed * When closed it throws an SQLException + * + * @throws SQLException if this ResultSet is closed */ private void checkNotClosed() throws SQLException { if (isClosed())
--- a/src/main/java/org/monetdb/jdbc/MonetStatement.java +++ b/src/main/java/org/monetdb/jdbc/MonetStatement.java @@ -1476,8 +1476,8 @@ public class MonetStatement * there were no warnings (or clearWarnings was called) this warning will * be the first, otherwise this warning will get appended to the current * warning. - * * @param reason the warning message + * @param sqlstate the SQLState code (5 characters) */ private void addWarning(final String reason, final String sqlstate) { SQLWarning warng = new SQLWarning(reason, sqlstate);
--- a/src/main/java/org/monetdb/mcl/io/BufferedMCLReader.java +++ b/src/main/java/org/monetdb/mcl/io/BufferedMCLReader.java @@ -69,7 +69,7 @@ public final class BufferedMCLReader { * * Set line type to PROMPT and line to null if the end of the response * has been reached. - * @throws IOException + * @throws IOException if exception occurred during reading */ public void advance() throws IOException { if (lineType == LineType.PROMPT) @@ -168,7 +168,7 @@ public final class BufferedMCLReader { /** * Close the wrapped Reader. - * @throws IOException + * @throws IOException if an IO exception occurs while talking to the server */ public void close() throws IOException { inner.close();
--- a/src/main/java/org/monetdb/mcl/net/MapiSocket.java +++ b/src/main/java/org/monetdb/mcl/net/MapiSocket.java @@ -432,6 +432,9 @@ public class MapiSocket { /* cannot (yet * @param database the database to connect to * @param hash the hash method(s) to use, or NULL for all supported hashes * @return the response string for the server + * @throws MCLParseException when parsing failed + * @throws MCLException if an MCL related error occurs + * @throws IOException when IO exception occurred */ private String getChallengeResponse( final String chalstr, @@ -730,6 +733,11 @@ public class MapiSocket { /* cannot (yet log.flush(); } + /** + * Set the HandshakeOptions + * + * @param handshakeOptions the options array + */ public void setHandshakeOptions(HandshakeOption<?>[] handshakeOptions) { this.handshakeOptions = handshakeOptions; } @@ -762,6 +770,7 @@ public class MapiSocket { /* cannot (yet /** * Constructs this BlockOutputStream, backed by the given * OutputStream. A BufferedOutputStream is internally used. + * @param out an OutputStream */ public BlockOutputStream(final OutputStream out) { // always use a buffered stream, even though we know how @@ -882,6 +891,7 @@ public class MapiSocket { /* cannot (yet /** * Constructs this BlockInputStream, backed by the given * InputStream. A BufferedInputStream is internally used. + * @param in an InputStream */ public BlockInputStream(final InputStream in) { // always use a buffered stream, even though we know how @@ -926,7 +936,10 @@ public class MapiSocket { /* cannot (yet * our blocks. Maybe it does speed up on slower links, then * consider this method a quick bug fix/workaround. * + * @param b a byte array to store read bytes + * @param len number of bytes to read * @return false if reading the block failed due to EOF + * @throws IOException if an IO error occurs while reading */ private boolean _read(final byte[] b, int len) throws IOException { int s; @@ -978,6 +991,9 @@ public class MapiSocket { /* cannot (yet * * If the stream is not positioned correctly, hell will break * loose. + * + * @return blockLen + * @throws IOException if an IO error occurs while reading */ private int readBlock() throws IOException { // read next two bytes (short) @@ -1102,6 +1118,7 @@ public class MapiSocket { /* cannot (yet /** * For internal use + * @return new Raw object */ Raw getRaw() { return new Raw(); @@ -1253,7 +1270,10 @@ public class MapiSocket { /* cannot (yet private byte[] promptBuffer; private Runnable cancellationCallback = null; - /** Create an UploadStream with the given chunk size */ + /** + * Create an UploadStream with the given chunk size + * @param chunkSize chunk size for the upload stream + */ UploadStream(final int chunkSize) { super(toMonet); if (chunkSize <= 0) {
--- a/src/main/java/org/monetdb/mcl/parser/HeaderLineParser.java +++ b/src/main/java/org/monetdb/mcl/parser/HeaderLineParser.java @@ -11,8 +11,7 @@ package org.monetdb.mcl.parser; /** * The HeaderLineParser is a generic MCLParser that extracts values from - * a metadata header in the MCL protocol either as string or integer - * values. + * a metadata header in the MCL protocol either as string or integer values. * * @author Fabian Groffen */ @@ -218,6 +217,7 @@ public final class HeaderLineParser exte * @param chrLine a character array holding the input data * @param start where the relevant data starts * @param stop where the relevant data stops + * @throws MCLParseException if an error occurs during parsing */ private final void getIntValues(final char[] chrLine, final int start, final int stop) throws MCLParseException { int elem = 0;
--- a/src/main/java/org/monetdb/util/SQLRestore.java +++ b/src/main/java/org/monetdb/util/SQLRestore.java @@ -78,16 +78,18 @@ public final class SQLRestore { } /** - * @return whether the server has responded with an error. Any - * error is regarded as fatal. + * Check whether the server has responded with an error. + * Any error is regarded as fatal. + * @return whether the server has responded with an error */ public boolean inErrorState() { return _errorState.get(); } /** - * @return the error message if inErrorState() is true. Behaviour is - * not defined if called before inErrorState is true. + * Get error message if inErrorState() is true. + * Behaviour is not defined if called before inErrorState is true. + * @return the error message */ public String getErrorMessage() { return _errorMessage;