Mercurial > hg > monetdb-java
changeset 32:57978db4ee57 embedded
Cleaned old code of the JDBC driver, fixed documentation
line wrap: on
line diff
--- a/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java +++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java @@ -1603,9 +1603,9 @@ public class MonetConnection extends Mon private String[] name; /** The types of the columns in this result */ private String[] type; - /** The max string length for each column in this result */ + /** The max string length for each columns in this result */ private int[] columnLengths; - /** The table for each column in this result */ + /** The table for each columns in this result */ private String[] tableNames; /** The query sequence number */ private final int seqnr; @@ -1811,7 +1811,7 @@ public class MonetConnection extends Mon if (!isSet[NAMES]) error += "name header missing\n"; if (!isSet[TYPES]) error += "type header missing\n"; if (!isSet[TABLES]) error += "table name header missing\n"; - if (!isSet[LENS]) error += "column width header missing\n"; + if (!isSet[LENS]) error += "columns width header missing\n"; if (error != "") throw new SQLException(error, "M0M10"); } @@ -2008,7 +2008,7 @@ public class MonetConnection extends Mon * <pre> * [ "value", 56 ] * </pre> - * where each column is separated by ",\t" and each tuple surrounded + * where each columns is separated by ",\t" and each tuple surrounded * by brackets ("[" and "]"). A DataBlockResponse object holds the * raw data as read from the server, in a parsed manner, ready for * easy retrieval.
--- a/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java +++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java @@ -433,7 +433,7 @@ public class MonetDatabaseMetaData exten /** * Internal utility method getConcatenatedStringFromQuery(String query) - * args: query: SQL SELECT query. Only the output of the first column is concatenated. + * args: query: SQL SELECT query. Only the output of the first columns is concatenated. * @return a String of query result values concatenated into one string, and values separated by comma's */ private String getConcatenatedStringFromQuery(String query) { @@ -443,7 +443,7 @@ public class MonetDatabaseMetaData exten try { st = con.createStatement(); rs = st.executeQuery(query); - // Fetch the first column output and concatenate the values into a StringBuilder separated by comma's + // Fetch the first columns output and concatenate the values into a StringBuilder separated by comma's boolean isfirst = true; while (rs.next()) { String value = rs.getString(1); @@ -548,7 +548,7 @@ public class MonetDatabaseMetaData exten } /** - * Is "ALTER TABLE" with an add column supported? + * Is "ALTER TABLE" with an add columns supported? * * @return true if so */ @@ -558,7 +558,7 @@ public class MonetDatabaseMetaData exten } /** - * Is "ALTER TABLE" with a drop column supported? + * Is "ALTER TABLE" with a drop columns supported? * * @return true if so */ @@ -568,7 +568,7 @@ public class MonetDatabaseMetaData exten } /** - * Is column aliasing supported? + * Is columns aliasing supported? * * <p>If so, the SQL AS clause can be used to provide names for * computed columns or to provide alias names for columns as @@ -580,7 +580,7 @@ public class MonetDatabaseMetaData exten * select count(C) as C_COUNT from T group by C; * * </pre><br> - * should return a column named as C_COUNT instead of count(C) + * should return a columns named as C_COUNT instead of count(C) * * @return true if so */ @@ -1343,14 +1343,14 @@ public class MonetDatabaseMetaData exten } /** - * Whats the limit on column name length. + * Whats the limit on columns name length. * I take some safety here, but it's just a varchar in MonetDB * - * @return the maximum column name length + * @return the maximum columns name length */ @Override public int getMaxColumnNameLength() { - return 1024; // In MonetDB the max length of column sys._columns.name is defined as 1024 + return 1024; // In MonetDB the max length of columns sys._columns.name is defined as 1024 } /** @@ -1396,7 +1396,7 @@ public class MonetDatabaseMetaData exten /** * What is the maximum number of columns in a table? * - * The theoretical max value of int column sys._columns.id is 2^31 -1 + * The theoretical max value of int columns sys._columns.id is 2^31 -1 * but this is for all columns of all tables in all schemas (including all data dictionary columns). * For one table we should reduce it to a more practical soft limit of say 100 thousand * @@ -1466,7 +1466,7 @@ public class MonetDatabaseMetaData exten */ @Override public int getMaxSchemaNameLength() { - return 1024; // In MonetDB the max length of column sys.schemas.name is defined as 1024 + return 1024; // In MonetDB the max length of columns sys.schemas.name is defined as 1024 } /** @@ -1476,7 +1476,7 @@ public class MonetDatabaseMetaData exten */ @Override public int getMaxProcedureNameLength() { - return 256; // In MonetDB the max length of column sys.functions.name is defined as 256 + return 256; // In MonetDB the max length of columns sys.functions.name is defined as 256 } /** @@ -1541,7 +1541,7 @@ public class MonetDatabaseMetaData exten */ @Override public int getMaxTableNameLength() { - return 1024; // In MonetDB the max length of column sys._tables.name is defined as 1024 + return 1024; // In MonetDB the max length of columns sys._tables.name is defined as 1024 } /** @@ -1562,7 +1562,7 @@ public class MonetDatabaseMetaData exten */ @Override public int getMaxUserNameLength() { - return 1024; // In MonetDB the max length of column sys.db_user_info.name is defined as 1024 + return 1024; // In MonetDB the max length of columns sys.db_user_info.name is defined as 1024 } /** @@ -1743,22 +1743,22 @@ public class MonetDatabaseMetaData exten * criteria are returned. They are ordered by PROCEDURE_SCHEM, PROCEDURE_NAME * and SPECIFIC_NAME. Within this, the return value, if any, is first. * Next are the parameter descriptions in call order. The - * column descriptions follow in column number order. + * columns descriptions follow in columns number order. * - * <p>Each row in the ResultSet is a parameter description or column + * <p>Each row in the ResultSet is a parameter description or columns * description with the following fields: * <ol> * <li><b>PROCEDURE_CAT</b> String => procedure catalog (may be null) * <li><b>PROCEDURE_SCHEM</b> String => procedure schema (may be null) * <li><b>PROCEDURE_NAME</b> String => procedure name - * <li><b>COLUMN_NAME</b> String => column/parameter name - * <li><b>COLUMN_TYPE</b> Short => kind of column/parameter: + * <li><b>COLUMN_NAME</b> String => columns/parameter name + * <li><b>COLUMN_TYPE</b> Short => kind of columns/parameter: * <ul><li>procedureColumnUnknown - nobody knows * <li>procedureColumnIn - IN parameter * <li>procedureColumnInOut - INOUT parameter * <li>procedureColumnOut - OUT parameter * <li>procedureColumnReturn - procedure return value - * <li>procedureColumnResult - result column in ResultSet + * <li>procedureColumnResult - result columns in ResultSet * </ul> * <li><b>DATA_TYPE</b> int => SQL type from java.sql.Types * <li><b>TYPE_NAME</b> String => SQL type name, for a UDT type the type name is fully qualified @@ -1771,8 +1771,8 @@ public class MonetDatabaseMetaData exten * <li>procedureNullable - allows NULL values * <li>procedureNullableUnknown - nullability unknown * </ul> - * <li><b>REMARKS</b> String => comment describing parameter/column - * <li><b>COLUMN_DEF</b> String => default value for the column, which should be interpreted as a string when the value is enclosed in single quotes (may be null) + * <li><b>REMARKS</b> String => comment describing parameter/columns + * <li><b>COLUMN_DEF</b> String => default value for the columns, which should be interpreted as a string when the value is enclosed in single quotes (may be null) * The string NULL (not enclosed in quotes) - if NULL was specified as the default value * TRUNCATE (not enclosed in quotes) - if the specified default value cannot be represented without truncation * NULL - if a default value was not specified @@ -1781,8 +1781,8 @@ public class MonetDatabaseMetaData exten * <li><b>CHAR_OCTET_LENGTH</b> int => the maximum length of binary and character based columns. For any other datatype the returned value is a NULL * <li><b>ORDINAL_POSITION</b> int => the ordinal position, starting from 1, for the input and output parameters for a procedure. * A value of 0 is returned if this row describes the procedure's return value. For result set columns, it is the ordinal position of the - * column in the result set starting from 1. If there are multiple result sets, the column ordinal positions are implementation defined. - * <li><b>IS_NULLABLE</b> String => ISO rules are used to determine the nullability for a column. + * columns in the result set starting from 1. If there are multiple result sets, the columns ordinal positions are implementation defined. + * <li><b>IS_NULLABLE</b> String => ISO rules are used to determine the nullability for a columns. * <ul><li>YES --- if the parameter can include NULLs * <li>NO --- if the parameter cannot include NULLs * <li>empty string --- if the nullability for the parameter is unknown @@ -1796,8 +1796,8 @@ public class MonetDatabaseMetaData exten * "" retrieves those without a schema; * null means that the schema name should not be used to narrow the search * @param procedureNamePattern - a procedure name pattern; must match the procedure name as it is stored in the database - * @param columnNamePattern - a column name pattern; must match the column name as it is stored in the database - * @return ResultSet - each row describes a stored procedure parameter or column + * @param columnNamePattern - a columns name pattern; must match the columns name as it is stored in the database + * @return ResultSet - each row describes a stored procedure parameter or columns * @throws SQLException if a database-access error occurs * @see #getSearchStringEscape */ @@ -1886,7 +1886,7 @@ public class MonetDatabaseMetaData exten /** * Returns the given string between two double quotes for usage as - * exact column or table name in SQL queries. + * exact columns or table name in SQL queries. * * @param in the string to quote * @return the quoted string @@ -1916,7 +1916,7 @@ public class MonetDatabaseMetaData exten * <li><b>TYPE_CAT</b> String => the types catalog (may be null) * <li><b>TYPE_SCHEM</b> String => the types schema (may be null) * <li><b>TYPE_NAME</b> String => type name (may be null) - * <li><b>SELF_REFERENCING_COL_NAME</b> String => name of the designated "identifier" column of a typed table (may be null) + * <li><b>SELF_REFERENCING_COL_NAME</b> String => name of the designated "identifier" columns of a typed table (may be null) * <li><b>REF_GENERATION</b> String => specifies how values in SELF_REFERENCING_COL_NAME are created. Values are "SYSTEM", "USER", "DERIVED". (may be null) * </ol> * @@ -2019,7 +2019,7 @@ public class MonetDatabaseMetaData exten * Get the schema names available in this database. The results * are ordered by schema name. * - * <P>The schema column is: + * <P>The schema columns is: * <OL> * <LI><B>TABLE_SCHEM</B> String => schema name * <LI><B>TABLE_CATALOG</B> String => catalog name (may be null) @@ -2032,7 +2032,7 @@ public class MonetDatabaseMetaData exten * @param schemaPattern a schema name; must match the schema name as * it is stored in the database; null means schema name * should not be used to narrow down the search. - * @return ResultSet each row has a single String column that is a + * @return ResultSet each row has a single String columns that is a * schema name * @throws SQLException if a database error occurs */ @@ -2063,13 +2063,13 @@ public class MonetDatabaseMetaData exten * Get the catalog names available in this database. The results * are ordered by catalog name. * - * <P>The catalog column is: + * <P>The catalog columns is: * <OL> * <LI><B>TABLE_CAT</B> String => catalog name * </OL> * * - * @return ResultSet each row has a single String column that is a + * @return ResultSet each row has a single String columns that is a * catalog name * @throws SQLException if a database error occurs */ @@ -2091,7 +2091,7 @@ public class MonetDatabaseMetaData exten * "LOCAL TEMPORARY", "ALIAS", "SYNONYM". * </OL> * - * @return ResultSet each row has a single String column that is a + * @return ResultSet each row has a single String columns that is a * table type * @throws SQLException if a database error occurs */ @@ -2118,19 +2118,19 @@ public class MonetDatabaseMetaData exten /** * Get a description of table columns available in a catalog. * - * <P>Only column descriptions matching the catalog, schema, table - * and column name criteria are returned. They are ordered by + * <P>Only columns descriptions matching the catalog, schema, table + * and columns name criteria are returned. They are ordered by * TABLE_SCHEM, TABLE_NAME and ORDINAL_POSITION. * - * <P>Each column description has the following columns: + * <P>Each columns description has the following columns: * <OL> * <LI><B>TABLE_CAT</B> String => table catalog (may be null) * <LI><B>TABLE_SCHEM</B> String => table schema (may be null) * <LI><B>TABLE_NAME</B> String => table name - * <LI><B>COLUMN_NAME</B> String => column name + * <LI><B>COLUMN_NAME</B> String => columns name * <LI><B>DATA_TYPE</B> int => SQL type from java.sql.Types * <LI><B>TYPE_NAME</B> String => Data source dependent type name - * <LI><B>COLUMN_SIZE</B> int => column size. For char or date + * <LI><B>COLUMN_SIZE</B> int => columns size. For char or date * types this is the maximum number of characters, for numeric or * decimal types this is precision. * <LI><B>BUFFER_LENGTH</B> is not used. @@ -2142,32 +2142,32 @@ public class MonetDatabaseMetaData exten * <LI> columnNullable - definitely allows NULL values * <LI> columnNullableUnknown - nullability unknown * </UL> - * <LI><B>REMARKS</B> String => comment describing column (may be null) + * <LI><B>REMARKS</B> String => comment describing columns (may be null) * <LI><B>COLUMN_DEF</B> String => default value (may be null) * <LI><B>SQL_DATA_TYPE</B> int => unused * <LI><B>SQL_DATETIME_SUB</B> int => unused * <LI><B>CHAR_OCTET_LENGTH</B> int => for char types the - * maximum number of bytes in the column - * <LI><B>ORDINAL_POSITION</B> int => index of column in table + * maximum number of bytes in the columns + * <LI><B>ORDINAL_POSITION</B> int => index of columns in table * (starting at 1) - * <LI><B>IS_NULLABLE</B> String => "NO" means column definitely - * does not allow NULL values; "YES" means the column might + * <LI><B>IS_NULLABLE</B> String => "NO" means columns definitely + * does not allow NULL values; "YES" means the columns might * allow NULL values. An empty string means nobody knows. * <LI><B>SCOPE_CATALOG</B> String => catalog of table that is the scope of a reference attribute (null if DATA_TYPE isn't REF) * <LI><B>SCOPE_SCHEMA</B> String => schema of table that is the scope of a reference attribute (null if the DATA_TYPE isn't REF) * <LI><B>SCOPE_TABLE</B> String => table name that this the scope of a reference attribute (null if the DATA_TYPE isn't REF) * <LI><B>SOURCE_DATA_TYPE</B> short => source type of a distinct type or user-generated Ref type, SQL type from java.sql.Types (null if DATA_TYPE isn't DISTINCT or user-generated REF) - * <LI><B>IS_AUTOINCREMENT</B> String => Indicates whether this column is auto incremented + * <LI><B>IS_AUTOINCREMENT</B> String => Indicates whether this columns is auto incremented * <UL> - * <LI> YES --- if the column is auto incremented - * <LI> NO --- if the column is not auto incremented - * <LI> empty string --- if it cannot be determined whether the column is auto incremented + * <LI> YES --- if the columns is auto incremented + * <LI> NO --- if the columns is not auto incremented + * <LI> empty string --- if it cannot be determined whether the columns is auto incremented * </UL> - * <LI><B>IS_GENERATEDCOLUMN</B> String => Indicates whether this is a generated column + * <LI><B>IS_GENERATEDCOLUMN</B> String => Indicates whether this is a generated columns * <UL> - * <LI> YES --- if this a generated column - * <LI> NO --- if this not a generated column - * <LI> empty string --- if it cannot be determined whether this is a generated column + * <LI> YES --- if this a generated columns + * <LI> NO --- if this not a generated columns + * <LI> empty string --- if it cannot be determined whether this is a generated columns * </UL> * </OL> * @@ -2179,8 +2179,8 @@ public class MonetDatabaseMetaData exten * null means that the schema name should not be used to narrow the search * @param tableNamePattern - a table name pattern; must match the table name as it is stored in the database * For all tables this should be "%" - * @param columnNamePattern - a column name pattern; must match the column name as it is stored in the database - * @return ResultSet - each row is a column description + * @param columnNamePattern - a columns name pattern; must match the columns name as it is stored in the database + * @return ResultSet - each row is a columns description * @throws SQLException if a database error occurs * @see #getSearchStringEscape */ @@ -2250,7 +2250,7 @@ public class MonetDatabaseMetaData exten * Get a description of the access rights for a table's columns. * MonetDB doesn't have this level of access rights. * - * <P>Only privileges matching the column name criteria are + * <P>Only privileges matching the columns name criteria are * returned. They are ordered by COLUMN_NAME and PRIVILEGE. * * <P>Each privilige description has the following columns: @@ -2258,7 +2258,7 @@ public class MonetDatabaseMetaData exten * <LI><B>TABLE_CAT</B> String => table catalog (may be null) * <LI><B>TABLE_SCHEM</B> String => table schema (may be null) * <LI><B>TABLE_NAME</B> String => table name - * <LI><B>COLUMN_NAME</B> String => column name + * <LI><B>COLUMN_NAME</B> String => columns name * <LI><B>GRANTOR</B> => grantor of access (may be null) * <LI><B>GRANTEE</B> String => grantee of access * <LI><B>PRIVILEGE</B> String => name of access (SELECT, @@ -2270,8 +2270,8 @@ public class MonetDatabaseMetaData exten * @param catalog a catalog name; "" retrieves those without a catalog * @param schemaPattern a schema name; "" retrieves those without a schema * @param tableNamePattern a table name - * @param columnNamePattern a column name pattern - * @return ResultSet each row is a column privilege description + * @param columnNamePattern a columns name pattern + * @return ResultSet each row is a columns privilege description * @see #getSearchStringEscape * @throws SQLException if a database error occurs */ @@ -2422,7 +2422,7 @@ public class MonetDatabaseMetaData exten * Get a description of a table's optimal set of columns that * uniquely identifies a row. They are ordered by SCOPE. * - * <P>Each column description has the following columns: + * <P>Each columns description has the following columns: * <OL> * <LI><B>SCOPE</B> short => actual scope of result * <UL> @@ -2430,18 +2430,18 @@ public class MonetDatabaseMetaData exten * <LI> bestRowTransaction - valid for remainder of current transaction * <LI> bestRowSession - valid for remainder of current session * </UL> - * <LI><B>COLUMN_NAME</B> String => column name + * <LI><B>COLUMN_NAME</B> String => columns name * <LI><B>DATA_TYPE</B> int => SQL data type from java.sql.Types * <LI><B>TYPE_NAME</B> String => Data source dependent type name * <LI><B>COLUMN_SIZE</B> int => precision * <LI><B>BUFFER_LENGTH</B> int => not used * <LI><B>DECIMAL_DIGITS</B> short => scale - * <LI><B>PSEUDO_COLUMN</B> short => is this a pseudo column + * <LI><B>PSEUDO_COLUMN</B> short => is this a pseudo columns * like an Oracle ROWID * <UL> - * <LI> bestRowUnknown - may or may not be pseudo column - * <LI> bestRowNotPseudo - is NOT a pseudo column - * <LI> bestRowPseudo - is a pseudo column + * <LI> bestRowUnknown - may or may not be pseudo columns + * <LI> bestRowNotPseudo - is NOT a pseudo columns + * <LI> bestRowPseudo - is a pseudo columns * </UL> * </OL> * @@ -2450,7 +2450,7 @@ public class MonetDatabaseMetaData exten * @param table a table name * @param scope the scope of interest; use same values as SCOPE * @param nullable include columns that are nullable? - * @return ResultSet each row is a column description + * @return ResultSet each row is a columns description * @throws SQLException if a database error occurs */ @Override @@ -2510,27 +2510,27 @@ public class MonetDatabaseMetaData exten * Get a description of a table's columns that are automatically * updated when any value in a row is updated. They are unordered. * - * <P>Each column description has the following columns: + * <P>Each columns description has the following columns: * <OL> * <LI><B>SCOPE</B> short => is not used - * <LI><B>COLUMN_NAME</B> String => column name + * <LI><B>COLUMN_NAME</B> String => columns name * <LI><B>DATA_TYPE</B> int => SQL data type from java.sql.Types * <LI><B>TYPE_NAME</B> String => Data source dependent type name * <LI><B>COLUMN_SIZE</B> int => precision - * <LI><B>BUFFER_LENGTH</B> int => length of column value in bytes + * <LI><B>BUFFER_LENGTH</B> int => length of columns value in bytes * <LI><B>DECIMAL_DIGITS</B> short => scale - * <LI><B>PSEUDO_COLUMN</B> short => is this a pseudo column like an Oracle ROWID + * <LI><B>PSEUDO_COLUMN</B> short => is this a pseudo columns like an Oracle ROWID * <UL> - * <LI> versionColumnUnknown - may or may not be pseudo column - * <LI> versionColumnNotPseudo - is NOT a pseudo column - * <LI> versionColumnPseudo - is a pseudo column + * <LI> versionColumnUnknown - may or may not be pseudo columns + * <LI> versionColumnNotPseudo - is NOT a pseudo columns + * <LI> versionColumnPseudo - is a pseudo columns * </UL> * </OL> * * @param catalog a catalog name; "" retrieves those without a catalog * @param schema a schema name; "" retrieves those without a schema * @param table a table name - * @return ResultSet each row is a column description + * @return ResultSet each row is a columns description * @throws SQLException if a database error occurs */ @Override @@ -2559,12 +2559,12 @@ public class MonetDatabaseMetaData exten * Get a description of a table's primary key columns. They * are ordered by COLUMN_NAME. * - * <P>Each column description has the following columns: + * <P>Each columns description has the following columns: * <OL> * <LI><B>TABLE_CAT</B> String => table catalog (may be null) * <LI><B>TABLE_SCHEM</B> String => table schema (may be null) * <LI><B>TABLE_NAME</B> String => table name - * <LI><B>COLUMN_NAME</B> String => column name + * <LI><B>COLUMN_NAME</B> String => columns name * <LI><B>KEY_SEQ</B> short => sequence number within primary key * <LI><B>PK_NAME</B> String => primary key name (may be null) * </OL> @@ -2573,7 +2573,7 @@ public class MonetDatabaseMetaData exten * @param schema a schema name pattern; "" retrieves those * without a schema * @param table a table name - * @return ResultSet each row is a primary key column description + * @return ResultSet each row is a primary key columns description * @throws SQLException if a database error occurs */ @Override @@ -2656,7 +2656,7 @@ public class MonetDatabaseMetaData exten * imported by a table). They are ordered by PKTABLE_CAT, * PKTABLE_SCHEM, PKTABLE_NAME, and KEY_SEQ. * - * <P>Each primary key column description has the following columns: + * <P>Each primary key columns description has the following columns: * <OL> * <LI><B>PKTABLE_CAT</B> String => primary key table catalog * being imported (may be null) @@ -2664,14 +2664,14 @@ public class MonetDatabaseMetaData exten * being imported (may be null) * <LI><B>PKTABLE_NAME</B> String => primary key table name * being imported - * <LI><B>PKCOLUMN_NAME</B> String => primary key column name + * <LI><B>PKCOLUMN_NAME</B> String => primary key columns name * being imported * <LI><B>FKTABLE_CAT</B> String => foreign key table catalog (may be null) * <LI><B>FKTABLE_SCHEM</B> String => foreign key table schema (may be null) * <LI><B>FKTABLE_NAME</B> String => foreign key table name - * <LI><B>FKCOLUMN_NAME</B> String => foreign key column name + * <LI><B>FKCOLUMN_NAME</B> String => foreign key columns name * <LI><B>KEY_SEQ</B> short => sequence number within foreign key - * (a value of 1 represents the first column of the foreign key, a value of 2 would represent the second column within the foreign key). + * (a value of 1 represents the first columns of the foreign key, a value of 2 would represent the second columns within the foreign key). * <LI><B>UPDATE_RULE</B> short => What happens to * foreign key when primary is updated: * <UL> @@ -2706,7 +2706,7 @@ public class MonetDatabaseMetaData exten * @param catalog a catalog name; "" retrieves those without a catalog * @param schema a schema name pattern; "" retrieves those without a schema * @param table a table name - * @return ResultSet each row is a primary key column description + * @return ResultSet each row is a primary key columns description * @see #getExportedKeys * @throws SQLException if a database error occurs */ @@ -2739,22 +2739,22 @@ public class MonetDatabaseMetaData exten * table's primary key columns (the foreign keys exported by a table). * They are ordered by FKTABLE_CAT, FKTABLE_SCHEM, FKTABLE_NAME, and KEY_SEQ. * - * <P>Each foreign key column description has the following columns: + * <P>Each foreign key columns description has the following columns: * <OL> * <LI><B>PKTABLE_CAT</B> String => primary key table catalog (may be null) * <LI><B>PKTABLE_SCHEM</B> String => primary key table schema (may be null) * <LI><B>PKTABLE_NAME</B> String => primary key table name - * <LI><B>PKCOLUMN_NAME</B> String => primary key column name + * <LI><B>PKCOLUMN_NAME</B> String => primary key columns name * <LI><B>FKTABLE_CAT</B> String => foreign key table catalog (may be null) * being exported (may be null) * <LI><B>FKTABLE_SCHEM</B> String => foreign key table schema (may be null) * being exported (may be null) * <LI><B>FKTABLE_NAME</B> String => foreign key table name * being exported - * <LI><B>FKCOLUMN_NAME</B> String => foreign key column name + * <LI><B>FKCOLUMN_NAME</B> String => foreign key columns name * being exported * <LI><B>KEY_SEQ</B> short => sequence number within foreign key - * (a value of 1 represents the first column of the foreign key, a value of 2 would represent the second column within the foreign key). + * (a value of 1 represents the first columns of the foreign key, a value of 2 would represent the second columns within the foreign key). * <LI><B>UPDATE_RULE</B> short => What happens to * foreign key when primary is updated: * <UL> @@ -2789,7 +2789,7 @@ public class MonetDatabaseMetaData exten * @param catalog a catalog name; "" retrieves those without a catalog * @param schema a schema name pattern; "" retrieves those without a schema * @param table a table name - * @return ResultSet each row is a foreign key column description + * @return ResultSet each row is a foreign key columns description * @see #getImportedKeys * @throws SQLException if a database error occurs */ @@ -2825,22 +2825,22 @@ public class MonetDatabaseMetaData exten * (most tables only import a foreign key from a table once.) * They are ordered by FKTABLE_CAT, FKTABLE_SCHEM, FKTABLE_NAME, and KEY_SEQ. * - * <P>Each foreign key column description has the following columns: + * <P>Each foreign key columns description has the following columns: * <OL> * <LI><B>PKTABLE_CAT</B> String => primary key table catalog (may be null) * <LI><B>PKTABLE_SCHEM</B> String => primary key table schema (may be null) * <LI><B>PKTABLE_NAME</B> String => primary key table name - * <LI><B>PKCOLUMN_NAME</B> String => primary key column name + * <LI><B>PKCOLUMN_NAME</B> String => primary key columns name * <LI><B>FKTABLE_CAT</B> String => foreign key table catalog (may be null) * being exported (may be null) * <LI><B>FKTABLE_SCHEM</B> String => foreign key table schema (may be null) * being exported (may be null) * <LI><B>FKTABLE_NAME</B> String => foreign key table name * being exported - * <LI><B>FKCOLUMN_NAME</B> String => foreign key column name + * <LI><B>FKCOLUMN_NAME</B> String => foreign key columns name * being exported * <LI><B>KEY_SEQ</B> short => sequence number within foreign key - * (a value of 1 represents the first column of the foreign key, a value of 2 would represent the second column within the foreign key). + * (a value of 1 represents the first columns of the foreign key, a value of 2 would represent the second columns within the foreign key). * <LI><B>UPDATE_RULE</B> short => What happens to * foreign key when primary is updated: * <UL> @@ -2878,7 +2878,7 @@ public class MonetDatabaseMetaData exten * @param fcatalog foreign key catalog name; "" retrieves those without a catalog * @param fschema foreign key schema name pattern; "" retrieves those without a schema * @param ftable koreign key table name - * @return ResultSet each row is a foreign key column description + * @return ResultSet each row is a foreign key columns description * @throws SQLException if a database error occurs * @see #getImportedKeys */ @@ -3016,7 +3016,7 @@ public class MonetDatabaseMetaData exten * Retrieves a description of the given table's indices and statistics. * They are ordered by NON_UNIQUE, TYPE, INDEX_NAME, and ORDINAL_POSITION. * - * <P>Each index column description has the following columns: + * <P>Each index columns description has the following columns: * <OL> * <LI><B>TABLE_CAT</B> String => table catalog (may be null) * <LI><B>TABLE_SCHEM</B> String => table schema (may be null) @@ -3035,11 +3035,11 @@ public class MonetDatabaseMetaData exten * <LI> tableIndexHashed - this is a hashed index * <LI> tableIndexOther - this is some other style of index * </UL> - * <LI><B>ORDINAL_POSITION</B> short => column sequence number + * <LI><B>ORDINAL_POSITION</B> short => columns sequence number * within index; zero when TYPE is tableIndexStatistic - * <LI><B>COLUMN_NAME</B> String => column name; null when TYPE is + * <LI><B>COLUMN_NAME</B> String => columns name; null when TYPE is * tableIndexStatistic - * <LI><B>ASC_OR_DESC</B> String => column sort sequence, "A" => ascending + * <LI><B>ASC_OR_DESC</B> String => columns sort sequence, "A" => ascending * "D" => descending, may be null if sort sequence is not supported; * null when TYPE is tableIndexStatistic * <LI><B>CARDINALITY</B> int => When TYPE is tableIndexStatisic then @@ -3060,7 +3060,7 @@ public class MonetDatabaseMetaData exten * @param approximate when true, result is allowed to reflect approximate * or out of data values; when false, results are requested to be * accurate - * @return ResultSet each row is an index column description + * @return ResultSet each row is an index columns description * @throws SQLException if a database occurs */ @Override @@ -3507,7 +3507,7 @@ public class MonetDatabaseMetaData exten * <LI><B>ATTR_TYPE_NAME</B> String => Data source dependent type name. * For a UDT, the type name is fully qualified. For a REF, the type name is * fully qualified and represents the target type of the reference type. - * <LI><B>ATTR_SIZE</B> int => column size. For char or date + * <LI><B>ATTR_SIZE</B> int => columns size. For char or date * types this is the maximum number of characters; for numeric or * decimal types this is precision. * <LI><B>DECIMAL_DIGITS</B> int => the number of fractional digits @@ -3518,16 +3518,16 @@ public class MonetDatabaseMetaData exten * <LI> attributeNullable - definitely allows NULL values * <LI> attributeNullableUnknown - nullability unknown * </UL> - * <LI><B>REMARKS</B> String => comment describing column (may be <code>null</code>) + * <LI><B>REMARKS</B> String => comment describing columns (may be <code>null</code>) * <LI><B>ATTR_DEF</B> String => default value (may be <code>null</code>) * <LI><B>SQL_DATA_TYPE</B> int => unused * <LI><B>SQL_DATETIME_SUB</B> int => unused * <LI><B>CHAR_OCTET_LENGTH</B> int => for char types the - * maximum number of bytes in the column - * <LI><B>ORDINAL_POSITION</B> int => index of column in table + * maximum number of bytes in the columns + * <LI><B>ORDINAL_POSITION</B> int => index of columns in table * (starting at 1) - * <LI><B>IS_NULLABLE</B> String => "NO" means column definitely - * does not allow NULL values; "YES" means the column might + * <LI><B>IS_NULLABLE</B> String => "NO" means columns definitely + * does not allow NULL values; "YES" means the columns might * allow NULL values. An empty string means unknown. * <LI><B>SCOPE_CATALOG</B> String => catalog of table that is the * scope of a reference attribute (<code>null</code> if DATA_TYPE isn't REF) @@ -3730,13 +3730,13 @@ public class MonetDatabaseMetaData exten * Get the schema names available in this database. The results * are ordered by schema name. * - * <P>The schema column is: + * <P>The schema columns is: * <OL> * <LI><B>TABLE_SCHEM</B> String => schema name * <LI><B>TABLE_CATALOG</B> String => catalog name (may be null) * </OL> * - * @return ResultSet each row has a single String column that is a + * @return ResultSet each row has a single String columns that is a * schema name * @throws SQLException if a database error occurs */ @@ -3788,7 +3788,7 @@ public class MonetDatabaseMetaData exten * property. This will typically contain information as * to where this property is stored in the database. * - * The ResultSet is sorted by the NAME column + * The ResultSet is sorted by the NAME columns * * @return A ResultSet object; each row is a supported client info * property, none in case of MonetDB's current JDBC driver @@ -3903,19 +3903,19 @@ public class MonetDatabaseMetaData exten * Only descriptions matching the schema, function and parameter name criteria are returned. * They are ordered by FUNCTION_CAT, FUNCTION_SCHEM, FUNCTION_NAME and SPECIFIC_ NAME. * Within this, the return value, if any, is first. Next are the parameter descriptions in call order. - * The column descriptions follow in column number order. + * The columns descriptions follow in columns number order. * * 1. FUNCTION_CAT String => function catalog (may be null) * 2. FUNCTION_SCHEM String => function schema (may be null) * 3. FUNCTION_NAME String => function name. This is the name used to invoke the function - * 4. COLUMN_NAME String => column/parameter name - * 5. COLUMN_TYPE Short => kind of column/parameter: + * 4. COLUMN_NAME String => columns/parameter name + * 5. COLUMN_TYPE Short => kind of columns/parameter: * functionColumnUnknown - nobody knows * functionColumnIn - IN parameter * functionColumnInOut - INOUT parameter * functionColumnOut - OUT parameter * functionColumnReturn - function return value - * functionColumnResult - Indicates that the parameter or column is a column in the ResultSet + * functionColumnResult - Indicates that the parameter or columns is a columns in the ResultSet * 6. DATA_TYPE int => SQL type from java.sql.Types * 7. TYPE_NAME String => SQL type name, for a UDT type the type name is fully qualified * 8. PRECISION int => precision @@ -3926,14 +3926,14 @@ public class MonetDatabaseMetaData exten * functionNoNulls - does not allow NULL values * functionNullable - allows NULL values * functionNullableUnknown - nullability unknown - * 13. REMARKS String => comment describing column/parameter + * 13. REMARKS String => comment describing columns/parameter * 14. CHAR_OCTET_LENGTH int => the maximum length of binary and character based parameters or columns. For any other datatype the returned value is a NULL * 15. ORDINAL_POSITION int => the ordinal position, starting from 1, for the input and output parameters. - * A value of 0 is returned if this row describes the function's return value. For result set columns, it is the ordinal position of the column in the result set starting from 1. - * 16. IS_NULLABLE String => ISO rules are used to determine the nullability for a parameter or column. - * YES --- if the parameter or column can include NULLs - * NO --- if the parameter or column cannot include NULLs - * empty string --- if the nullability for the parameter or column is unknown + * A value of 0 is returned if this row describes the function's return value. For result set columns, it is the ordinal position of the columns in the result set starting from 1. + * 16. IS_NULLABLE String => ISO rules are used to determine the nullability for a parameter or columns. + * YES --- if the parameter or columns can include NULLs + * NO --- if the parameter or columns cannot include NULLs + * empty string --- if the nullability for the parameter or columns is unknown * 17. SPECIFIC_NAME String => the name which uniquely identifies this function within its schema. * This is a user specified, or DBMS generated, name that may be different then the FUNCTION_NAME for example with overload functions * @@ -3948,9 +3948,9 @@ public class MonetDatabaseMetaData exten * @param functionNamePattern a procedure name pattern; must match the * function name as it is stored in the database * @param columnNamePattern a parameter name pattern; must match the - * parameter or column name as it is stored in the database + * parameter or columns name as it is stored in the database * @return ResultSet - each row describes a user function parameter, - * column or return type + * columns or return type * @throws SQLException - if a database access error occurs */ @Override @@ -4024,32 +4024,32 @@ public class MonetDatabaseMetaData exten * necessarily be able to be modified. * If there are no pseudo or hidden columns, an empty ResultSet is returned. * - * Only column descriptions matching the catalog, schema, table and column name criteria are returned. + * Only columns descriptions matching the catalog, schema, table and columns name criteria are returned. * They are ordered by TABLE_CAT,TABLE_SCHEM, TABLE_NAME and COLUMN_NAME. * - * Each column description has the following columns: + * Each columns description has the following columns: * * 1. TABLE_CAT String => table catalog (may be null) * 2. TABLE_SCHEM String => table schema (may be null) * 3. TABLE_NAME String => table name - * 4. COLUMN_NAME String => column name + * 4. COLUMN_NAME String => columns name * 5. DATA_TYPE int => SQL type from java.sql.Types - * 6. COLUMN_SIZE int => column size. + * 6. COLUMN_SIZE int => columns size. * 7. DECIMAL_DIGITS int => the number of fractional digits. Null is returned for data types where DECIMAL_DIGITS is not applicable. * 8. NUM_PREC_RADIX int => Radix (typically either 10 or 2) - * 9. COLUMN_USAGE String => The allowed usage for the column. The value returned will correspond to the enum name returned by PseudoColumnUsage.name() - * 10. REMARKS String => comment describing column (may be null) - * 11. CHAR_OCTET_LENGTH int => for char types the maximum number of bytes in the column - * 12. IS_NULLABLE String => ISO rules are used to determine the nullability for a column. - * YES --- if the column can include NULLs - * NO --- if the column cannot include NULLs - * empty string --- if the nullability for the column is unknown + * 9. COLUMN_USAGE String => The allowed usage for the columns. The value returned will correspond to the enum name returned by PseudoColumnUsage.name() + * 10. REMARKS String => comment describing columns (may be null) + * 11. CHAR_OCTET_LENGTH int => for char types the maximum number of bytes in the columns + * 12. IS_NULLABLE String => ISO rules are used to determine the nullability for a columns. + * YES --- if the columns can include NULLs + * NO --- if the columns cannot include NULLs + * empty string --- if the nullability for the columns is unknown * * @param catalog a catalog name * @param schemaPattern a schema name pattern * @param tableNamePattern a table name pattern - * @param columnNamePattern a column name pattern - * @return ResultSet where each row is a column description + * @param columnNamePattern a columns name pattern + * @return ResultSet where each row is a columns description * @throws SQLException if a database access error occurs */ @Override @@ -4081,9 +4081,9 @@ public class MonetDatabaseMetaData exten /** * Retrieves whether a generated key will always be returned if the - * column name(s) or index(es) specified for the auto generated key - * column(s) are valid and the statement succeeds. The key that is - * returned may or may not be based on the column(s) for the auto + * columns name(s) or index(es) specified for the auto generated key + * columns(s) are valid and the statement succeeds. The key that is + * returned may or may not be based on the columns(s) for the auto * generated key. * * @return true if so, false otherwise
--- a/src/main/java/nl/cwi/monetdb/jdbc/MonetPreparedStatement.java +++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetPreparedStatement.java @@ -158,7 +158,7 @@ public class MonetPreparedStatement continue; schema[i] = rs.getString("schema"); table[i] = rs.getString("table"); - column[i] = rs.getString("column"); + column[i] = rs.getString("columns"); } rs.close(); @@ -197,7 +197,7 @@ public class MonetPreparedStatement scale = null; schema = null; table = null; - column = null; + columns = null; values = null; id = -1; size = -1; @@ -281,7 +281,7 @@ public class MonetPreparedStatement */ @Override public ResultSet executeQuery() throws SQLException{ - if (execute() != true) + if (!execute()) throw new SQLException("Query did not produce a result set", "M1M19"); return getResultSet(); @@ -305,7 +305,7 @@ public class MonetPreparedStatement */ @Override public int executeUpdate() throws SQLException { - if (execute() != false) + if (execute()) throw new SQLException("Query produced a result set", "M1M17"); return getUpdateCount(); @@ -319,7 +319,7 @@ 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 + * result set columns number or an SQLException when not found */ private int getColumnIdx(int colnr) throws SQLException { int curcol = 0; @@ -330,7 +330,7 @@ public class MonetPreparedStatement if (curcol == colnr) return i; } - throw new SQLException("No such column with index: " + colnr, "M1M05"); + throw new SQLException("No such columns with index: " + colnr, "M1M05"); } /** * Returns the index (0..size-1) in the backing arrays for the given @@ -365,7 +365,6 @@ public class MonetPreparedStatement * * @return the description of a ResultSet object's columns or null if the * driver cannot return a ResultSetMetaData object - * @throws SQLException if a database access error occurs */ @Override public ResultSetMetaData getMetaData() { @@ -377,7 +376,7 @@ public class MonetPreparedStatement /** * Returns the number of columns in this ResultSet object. * - * @returns the number of columns + * @return the number of columns */ @Override public int getColumnCount() { @@ -391,17 +390,17 @@ public class MonetPreparedStatement } /** - * Indicates whether the designated column is automatically numbered. + * Indicates whether the designated columns is automatically numbered. * - * @param column the first column is 1, the second is 2, ... + * @param column the first columns is 1, the second is 2, ... * @return true if so; false otherwise * @throws SQLException if a database access error occurs */ @Override public boolean isAutoIncrement(int column) throws SQLException { /* TODO: in MonetDB only numeric (int, decimal) columns could be autoincrement/serial - * This however requires an expensive dbmd.getColumns(null, schema, table, column) - * query call to pull the IS_AUTOINCREMENT value for this column. + * This however requires an expensive dbmd.getColumns(null, schema, table, columns) + * query call to pull the IS_AUTOINCREMENT value for this columns. * See also ResultSetMetaData.isAutoIncrement() */ // For now we simply allways return false. @@ -409,10 +408,10 @@ public class MonetPreparedStatement } /** - * Indicates whether a column's case matters. + * Indicates whether a columns's case matters. * - * @param column the first column is 1, the second is 2, ... - * @returns false + * @param column the first columns is 1, the second is 2, ... + * @return false */ @Override public boolean isCaseSensitive(int column) throws SQLException { @@ -436,13 +435,13 @@ public class MonetPreparedStatement } /** - * Indicates whether the designated column can be used in a + * Indicates whether the designated columns can be used in a * where clause. * * Returning true for all here, even for CLOB, BLOB. * - * @param column the first column is 1, the second is 2, ... - * @returns true + * @param column the first columns is 1, the second is 2, ... + * @return true */ @Override public boolean isSearchable(int column) { @@ -450,14 +449,14 @@ public class MonetPreparedStatement } /** - * Indicates whether the designated column is a cash value. + * Indicates whether the designated columns is a cash value. * From the MonetDB database perspective it is by definition * unknown whether the value is a currency, because there are * no currency datatypes such as MONEY. With this knowledge * we can always return false here. * - * @param column the first column is 1, the second is 2, ... - * @returns false + * @param column the first columns is 1, the second is 2, ... + * @return false */ @Override public boolean isCurrency(int column) { @@ -465,11 +464,11 @@ public class MonetPreparedStatement } /** - * Indicates whether values in the designated column are signed + * Indicates whether values in the designated columns are signed * numbers. * Within MonetDB all numeric types (except oid and ptr) are signed. * - * @param column the first column is 1, the second is 2, ... + * @param column the first columns is 1, the second is 2, ... * @return true if so; false otherwise */ @Override @@ -504,13 +503,13 @@ public class MonetPreparedStatement } /** - * Indicates the designated column's normal maximum width in + * Indicates the designated columns's normal maximum width in * characters. * - * @param column the first column is 1, the second is 2, ... + * @param column the first columns is 1, the second is 2, ... * @return the normal maximum number of characters allowed as the - * width of the designated column - * @throws SQLException if there is no such column + * width of the designated columns + * @throws SQLException if there is no such columns */ @Override public int getColumnDisplaySize(int column) throws SQLException { @@ -522,9 +521,9 @@ public class MonetPreparedStatement } /** - * Get the designated column's table's schema. + * Get the designated columns's table's schema. * - * @param column the first column is 1, the second is 2, ... + * @param column the first columns is 1, the second is 2, ... * @return schema name or "" if not applicable * @throws SQLException if a database access error occurs */ @@ -538,9 +537,9 @@ public class MonetPreparedStatement } /** - * Gets the designated column's table name. + * Gets the designated columns's table name. * - * @param column the first column is 1, the second is 2, ... + * @param column the first columns is 1, the second is 2, ... * @return table name or "" if not applicable */ @Override @@ -553,12 +552,12 @@ public class MonetPreparedStatement } /** - * Get the designated column's number of decimal digits. + * Get the designated columns's number of decimal digits. * This method is currently very expensive as it needs to * retrieve the information from the database using an SQL * query. * - * @param column the first column is 1, the second is 2, ... + * @param column the first columns is 1, the second is 2, ... * @return precision * @throws SQLException if a database access error occurs */ @@ -572,12 +571,12 @@ public class MonetPreparedStatement } /** - * Gets the designated column's number of digits to right of + * Gets the designated columns's number of digits to right of * the decimal point. This method is currently very * expensive as it needs to retrieve the information from * the database using an SQL query. * - * @param column the first column is 1, the second is 2, ... + * @param column the first columns is 1, the second is 2, ... * @return scale * @throws SQLException if a database access error occurs */ @@ -592,11 +591,11 @@ public class MonetPreparedStatement /** * Indicates the nullability of values in the designated - * column. This method is currently very expensive as it + * columns. This method is currently very expensive as it * needs to retrieve the information from the database using * an SQL query. * - * @param column the first column is 1, the second is 2, ... + * @param column the first columns is 1, the second is 2, ... * @return nullability * @throws SQLException if a database access error occurs */ @@ -606,12 +605,12 @@ public class MonetPreparedStatement } /** - * Gets the designated column's table's catalog name. + * Gets the designated columns's table's catalog name. * MonetDB does not support the catalog naming concept as in: catalog.schema.table naming scheme * - * @param column the first column is 1, the second is 2, ... + * @param column the first columns is 1, the second is 2, ... * @return the name of the catalog for the table in which the given - * column appears or "" if not applicable + * columns appears or "" if not applicable */ @Override public String getCatalogName(int column) throws SQLException { @@ -619,11 +618,11 @@ public class MonetPreparedStatement } /** - * Indicates whether the designated column is definitely not + * Indicates whether the designated columns is definitely not * writable. MonetDB does not support cursor updates, so * nothing is writable. * - * @param column the first column is 1, the second is 2, ... + * @param column the first columns is 1, the second is 2, ... * @return true if so; false otherwise */ @Override @@ -633,9 +632,9 @@ public class MonetPreparedStatement /** * Indicates whether it is possible for a write on the - * designated column to succeed. + * designated columns to succeed. * - * @param column the first column is 1, the second is 2, ... + * @param column the first columns is 1, the second is 2, ... * @return true if so; false otherwise */ @Override @@ -644,10 +643,10 @@ public class MonetPreparedStatement } /** - * Indicates whether a write on the designated column will + * Indicates whether a write on the designated columns will * definitely succeed. * - * @param column the first column is 1, the second is 2, ... + * @param column the first columns is 1, the second is 2, ... * @return true if so; false otherwise */ @Override @@ -659,16 +658,16 @@ public class MonetPreparedStatement * Returns the fully-qualified name of the Java class whose * instances are manufactured if the method * ResultSet.getObject is called to retrieve a value from - * the column. ResultSet.getObject may return a subclass of + * the columns. ResultSet.getObject may return a subclass of * the class returned by this method. * - * @param column the first column is 1, the second is 2, ... + * @param column the first columns is 1, the second is 2, ... * @return the fully-qualified name of the class in the Java * programming language that would be used by the method * ResultSet.getObject to retrieve the value in the - * specified column. This is the class name used for custom + * specified columns. This is the class name used for custom * mapping. - * @throws SQLException if there is no such column + * @throws SQLException if there is no such columns */ @Override public String getColumnClassName(int column) throws SQLException { @@ -676,13 +675,13 @@ public class MonetPreparedStatement } /** - * Gets the designated column's suggested title for use in + * Gets the designated columns's suggested title for use in * printouts and displays. This is currently equal to * getColumnName(). * - * @param column the first column is 1, the second is 2, ... - * @return the suggested column title - * @throws SQLException if there is no such column + * @param column the first columns is 1, the second is 2, ... + * @return the suggested columns title + * @throws SQLException if there is no such columns */ @Override public String getColumnLabel(int column) throws SQLException { @@ -690,11 +689,11 @@ public class MonetPreparedStatement } /** - * Gets the designated column's name + * Gets the designated columns's name * - * @param column the first column is 1, the second is 2, ... - * @return the column name - * @throws SQLException if there is no such column + * @param colnr the first columns is 1, the second is 2, ... + * @return the columns name + * @throws SQLException if there is no such columns */ @Override public String getColumnName(int colnr) throws SQLException { @@ -706,11 +705,11 @@ public class MonetPreparedStatement } /** - * Retrieves the designated column's SQL type. + * Retrieves the designated columns's SQL type. * - * @param column the first column is 1, the second is 2, ... + * @param column the first columns is 1, the second is 2, ... * @return SQL type from java.sql.Types - * @throws SQLException if there is no such column + * @throws SQLException if there is no such columns */ @Override public int getColumnType(int column) throws SQLException { @@ -722,13 +721,13 @@ public class MonetPreparedStatement } /** - * Retrieves the designated column's database-specific type name. + * Retrieves the designated columns's database-specific type name. * - * @param column the first column is 1, the second is 2, ... - * @return type name used by the database. If the column type is a + * @param column the first columns is 1, the second is 2, ... + * @return type name used by the database. If the columns type is a * user-defined type, then a fully-qualified type name is * returned. - * @throws SQLException if there is no such column + * @throws SQLException if there is no such columns */ @Override public String getColumnTypeName(int column) throws SQLException { @@ -1234,11 +1233,8 @@ public class MonetPreparedStatement } StringBuilder hex = new StringBuilder(x.length * 2); - byte b; - for (int i = 0; i < x.length; i++) { - b = x[i]; - hex.append(HEXES.charAt((b & 0xF0) >> 4)) - .append(HEXES.charAt((b & 0x0F))); + for (byte aX : x) { + hex.append(HEXES.charAt((aX & 0xF0) >> 4)).append(HEXES.charAt((aX & 0x0F))); } setValue(parameterIndex, "blob '" + hex.toString() + "'"); } @@ -1641,7 +1637,7 @@ public class MonetPreparedStatement @Override public void setNull(int parameterIndex, int sqlType) throws SQLException { // we discard the given type here, the backend converts the - // value NULL to whatever it needs for the column + // value NULL to whatever it needs for the columns setValue(parameterIndex, "NULL"); } @@ -1831,7 +1827,7 @@ public class MonetPreparedStatement } break; case Types.BIT: case Types.BOOLEAN: - setBoolean(parameterIndex, (Boolean.valueOf((String)x)).booleanValue()); + setBoolean(parameterIndex, Boolean.valueOf((String) x)); break; case Types.CHAR: case Types.VARCHAR: @@ -2538,8 +2534,8 @@ public class MonetPreparedStatement /** * Transforms the prepare query into a simple SQL query by replacing - * the ?'s with the given column contents. - * Mind that the JDBC specs allow `reuse' of a value for a column over + * the ?'s with the given columns contents. + * Mind that the JDBC specs allow `reuse' of a value for a columns over * multiple executes. * * @return the simple SQL string for the prepare query
--- a/src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java +++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java @@ -145,11 +145,10 @@ public class MonetResultSet extends Mone * DO NOT USE THIS CONSTRUCTOR IF YOU ARE NOT EXTENDING THIS OBJECT! * * @param statement the statement which created this ResultSet - * @param columns the column names - * @param types the column types + * @param columns the columns names + * @param types the columns types * @param results the number of rows in the ResultSet * @throws IllegalArgumentException if communicating with monet failed - * @throws SQLException is a protocol error occurs */ MonetResultSet( Statement statement, @@ -315,13 +314,13 @@ public class MonetResultSet extends Mone // Chapter 14.2.3 from Sun JDBC 3.0 specification /** - * Maps the given ResultSet column name to its ResultSet column index. - * Column names supplied to getter methods are case insensitive. If a select - * list contains the same column more than once, the first instance of the - * column will be returned. + * Maps the given ResultSet columns name to its ResultSet columns index. + * QueryResultSetColumn names supplied to getter methods are case insensitive. If a select + * list contains the same columns more than once, the first instance of the + * columns will be returned. * - * @param columnName the name of the column - * @return the column index of the given column name + * @param columnName the name of the columns + * @return the columns index of the given columns name * @throws SQLException if the ResultSet object does not contain columnName */ @Override @@ -338,7 +337,7 @@ public class MonetResultSet extends Mone return i + 1; } } - throw new SQLException("No such column name: " + columnName, "M1M05"); + throw new SQLException("No such columns name: " + columnName, "M1M05"); } /** @@ -385,19 +384,19 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row + * Retrieves the value of the designated columns in the current row * of this ResultSet object as a stream of uninterpreted bytes. The * value can then be read in chunks from the stream. This method is * particularly suitable for retrieving large LONGVARBINARY values. * <br/><br/> * Note: All the data in the returned stream must be read prior to - * getting the value of any other column. The next call to a getter + * getting the value of any other columns. The next call to a getter * method implicitly closes the stream. Also, a stream may return 0 * when the method InputStream.available is called whether there is * data available or not. * - * @param columnIndex the first column is 1, the second is 2, ... - * @return a Java input stream that delivers the database column + * @param columnIndex the first columns is 1, the second is 2, ... + * @return a Java input stream that delivers the database columns * value as a stream of uninterpreted bytes; if the value is SQL * NULL, the value returned is null * @throws SQLException if the columnIndex is not valid; if a @@ -428,21 +427,21 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row + * Retrieves the value of the designated columns in the current row * of this ResultSet object as a stream of uninterpreted bytes. The * value can then be read in chunks from the stream. This method is * particularly suitable for retrieving large LONGVARBINARY values. * <br/><br/> * Note: All the data in the returned stream must be read prior to - * getting the value of any other column. The next call to a getter + * getting the value of any other columns. The next call to a getter * method implicitly closes the stream. Also, a stream may return 0 * when the method available is called whether there is data * available or not. * - * @param columnName the label for the column specified with + * @param columnName the label for the columns specified with * the SQL AS clause. If the SQL AS clause was not specified, then - * the label is the name of the column - * @return a Java input stream that delivers the database column + * the label is the name of the columns + * @return a Java input stream that delivers the database columns * value as a stream of uninterpreted bytes; if the value is SQL * NULL, the result is null * @throws SQLException if the columnLabel is not valid; if a @@ -455,11 +454,11 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row + * Retrieves the value of the designated columns in the current row * of this ResultSet object as a java.io.Reader object. * - * @param columnIndex the first column is 1, the second is 2, ... - * @return a java.io.Reader object that contains the column value; + * @param columnIndex the first columns is 1, the second is 2, ... + * @return a java.io.Reader object that contains the columns value; * if the value is SQL NULL, the value returned is null in * the Java programming language. * @throws SQLException if a database access error occurs @@ -480,11 +479,11 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row + * Retrieves the value of the designated columns in the current row * of this ResultSet object as a java.io.Reader object. * - * @param columnName the name of the column - * @return a java.io.Reader object that contains the column value; + * @param columnName the name of the columns + * @return a java.io.Reader object that contains the columns value; * if the value is SQL NULL, the value returned is null in * the Java programming language. * @throws SQLException if a database access error occurs @@ -495,13 +494,13 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row + * Retrieves the value of the designated columns in the current row * of this ResultSet object as a java.io.Reader object. It is * intended for use when accessing NCHAR,NVARCHAR and LONGNVARCHAR * columns. * - * @param columnIndex the first column is 1, the second is 2, ... - * @return a java.io.Reader object that contains the column value; + * @param columnIndex the first columns is 1, the second is 2, ... + * @return a java.io.Reader object that contains the columns value; * if the value is SQL NULL, the value returned is null in * the Java programming language. * @throws SQLException if a database access error occurs @@ -514,13 +513,13 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row + * Retrieves the value of the designated columns in the current row * of this ResultSet object as a java.io.Reader object. It is * intended for use when accessing NCHAR,NVARCHAR and LONGNVARCHAR * columns. * - * @param columnName the name of the column - * @return a java.io.Reader object that contains the column value; + * @param columnName the name of the columns + * @return a java.io.Reader object that contains the columns value; * if the value is SQL NULL, the value returned is null in * the Java programming language. * @throws SQLException if a database access error occurs @@ -533,13 +532,13 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row + * Retrieves the value of the designated columns in the current row * of this ResultSet object as a Blob object in the Java programming * language. * - * @param columnIndex the first column is 1, the second is 2, ... + * @param columnIndex the first columns is 1, the second is 2, ... * @return a Blob object representing the SQL BLOB value in the - * specified column + * specified columns * @throws SQLException if a database access error occurs */ @Override @@ -558,14 +557,14 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row + * Retrieves the value of the designated columns in the current row * of this ResultSet object as a Blob object in the Java programming * language. * - * @param colName the name of the column from which to retrieve + * @param colName the name of the columns from which to retrieve * the value * @return a Blob object representing the SQL BLOB value in the - * specified column + * specified columns * @throws SQLException if a database access error occurs */ @Override @@ -574,13 +573,13 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row + * Retrieves the value of the designated columns in the current row * of this ResultSet object as a Clob object in the * Java programming language. * - * @param columnIndex the first column is 1, the second is 2, ... + * @param columnIndex the first columns is 1, the second is 2, ... * @return a Clob object representing the SQL CLOB value in the - * specified column + * specified columns * @throws SQLException if a database access error occurs */ @Override @@ -599,14 +598,14 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row + * Retrieves the value of the designated columns in the current row * of this ResultSet object as a Clob object in the * Java programming language. * - * @param colName the name of the column from which to retrieve + * @param colName the name of the columns from which to retrieve * the value * @return a Clob object representing the SQL CLOB value in the - * specified column + * specified columns * @throws SQLException if a database access error occurs */ @Override @@ -615,13 +614,13 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row + * Retrieves the value of the designated columns in the current row * of this ResultSet object as a NClob object in the * Java programming language. * - * @param i the first column is 1, the second is 2, ... + * @param i the first columns is 1, the second is 2, ... * @return a NClob object representing the SQL NCLOB value in the - * specified column + * specified columns * @throws SQLException if a database access error occurs * @throws SQLFeatureNotSupportedException the JDBC driver does * not support this method @@ -632,14 +631,14 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row + * Retrieves the value of the designated columns in the current row * of this ResultSet object as a NClob object in the * Java programming language. * - * @param colName the name of the column from which to retrieve + * @param colName the name of the columns from which to retrieve * the value * @return a NClob object representing the SQL NCLOB value in the - * specified column + * specified columns * @throws SQLException if a database access error occurs * @throws SQLFeatureNotSupportedException the JDBC driver does * not support this method @@ -650,11 +649,11 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row of this + * Retrieves the value of the designated columns in the current row of this * ResultSet object as a java.math.BigDecimal with full precision. * - * @param columnIndex the first column is 1, the second is 2, ... - * @return the column value (full precision); if the value is SQL NULL, + * @param columnIndex the first columns is 1, the second is 2, ... + * @return the columns value (full precision); if the value is SQL NULL, * the value returned is null in the Java programming language. * @throws SQLException if a database access error occurs */ @@ -676,12 +675,12 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row of this + * Retrieves the value of the designated columns in the current row of this * ResultSet object as a java.math.BigDecimal with full precision. * - * @param columnIndex the first column is 1, the second is 2, ... + * @param columnIndex the first columns is 1, the second is 2, ... * @param scale the number of digits to the right of the decimal point - * @return the column value (full precision); if the value is SQL NULL, + * @return the columns value (full precision); if the value is SQL NULL, * the value returned is null in the Java programming language. * @throws SQLException if a database access error occurs */ @@ -709,11 +708,11 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row of this + * Retrieves the value of the designated columns in the current row of this * ResultSet object as a java.math.BigDecimal with full precision. * - * @param columnName the SQL name of the column - * @return the column value (full precision); if the value is SQL NULL, + * @param columnName the SQL name of the columns + * @return the columns value (full precision); if the value is SQL NULL, * the value returned is null in the Java programming language. * @throws SQLException if a database access error occurs */ @@ -723,12 +722,12 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row of this + * Retrieves the value of the designated columns in the current row of this * ResultSet object as a java.math.BigDecimal with full precision. * - * @param columnName the SQL name of the column + * @param columnName the SQL name of the columns * @param scale the number of digits to the right of the decimal point - * @return the column value (full precision); if the value is SQL NULL, + * @return the columns value (full precision); if the value is SQL NULL, * the value returned is null in the Java programming language. * @throws SQLException if a database access error occurs */ @@ -742,13 +741,13 @@ public class MonetResultSet extends Mone // See Sun JDBC Specification 3.0 Table B-6 /** - * Retrieves the value of the designated column in the current row of this + * Retrieves the value of the designated columns in the current row of this * ResultSet object as a boolean in the Java programming language. * - * @param columnIndex the first column is 1, the second is 2, ... - * @return the column value; if the value is SQL NULL, the value returned + * @param columnIndex the first columns is 1, the second is 2, ... + * @return the columns value; if the value is SQL NULL, the value returned * is false - * @throws SQLException if there is no such column + * @throws SQLException if there is no such columns */ @Override public boolean getBoolean(int columnIndex) throws SQLException { @@ -779,28 +778,16 @@ public class MonetResultSet extends Mone case Types.TINYINT: case Types.SMALLINT: case Types.INTEGER: - if (getInt(columnIndex) == 0) { - return false; - } - return true; + return getInt(columnIndex) != 0; case Types.BIGINT: - if (getLong(columnIndex) == 0L) { - return false; - } - return true; + return getLong(columnIndex) != 0L; case Types.DOUBLE: case Types.FLOAT: case Types.REAL: - if (getDouble(columnIndex) == 0.0) { - return false; - } - return true; + return getDouble(columnIndex) != 0.0; case Types.DECIMAL: case Types.NUMERIC: - if (getBigDecimal(columnIndex).compareTo(BigDecimal.ZERO) == 0) { - return false; - } - return true; + return getBigDecimal(columnIndex).compareTo(BigDecimal.ZERO) != 0; default: throw new SQLException("Conversion from " + types[columnIndex - 1] + " to boolean type not supported", "M1M05"); } @@ -810,11 +797,11 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row of this + * Retrieves the value of the designated columns in the current row of this * ResultSet object as a boolean in the Java programming language. * - * @param columnName the SQL name of the column - * @return the column value; if the value is SQL NULL, the value returned + * @param columnName the SQL name of the columns + * @return the columns value; if the value is SQL NULL, the value returned * is false * @throws SQLException if the ResultSet object does not contain columnName */ @@ -824,11 +811,11 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row of this + * Retrieves the value of the designated columns in the current row of this * ResultSet object as a byte in the Java programming language. * - * @param columnIndex the first column is 1, the second is 2, ... - * @return the column value; if the value is SQL NULL, the value returned + * @param columnIndex the first columns is 1, the second is 2, ... + * @return the columns value; if the value is SQL NULL, the value returned * is 0 * @throws SQLException if a database access error occurs */ @@ -850,11 +837,11 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row of this + * Retrieves the value of the designated columns in the current row of this * ResultSet object as a byte in the Java programming language. * - * @param columnName the SQL name of the column - * @return the column value; if the value is SQL NULL, the value returned + * @param columnName the SQL name of the columns + * @return the columns value; if the value is SQL NULL, the value returned * is 0 * @throws SQLException if a database access error occurs */ @@ -864,12 +851,12 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row of this + * Retrieves the value of the designated columns in the current row of this * ResultSet object as a byte array in the Java programming language. The * bytes represent the raw values returned by the driver. * - * @param columnIndex the first column is 1, the second is 2, ... - * @return the column value; if the value is SQL NULL, the value returned + * @param columnIndex the first columns is 1, the second is 2, ... + * @return the columns value; if the value is SQL NULL, the value returned * is null * @throws SQLException if a database access error occurs */ @@ -909,7 +896,7 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row of this + * Retrieves the value of the designated columns in the current row of this * ResultSet object as a byte array in the Java programming language. The * bytes represent the raw values returned by the driver. * @@ -918,8 +905,8 @@ public class MonetResultSet extends Mone * an encoding into a sequence of bytes using the platform's default * charset. * - * @param columnName the SQL name of the column - * @return the column value; if the value is SQL NULL, the value returned + * @param columnName the SQL name of the columns + * @return the columns value; if the value is SQL NULL, the value returned * is null * @throws SQLException if a database access error occurs */ @@ -971,13 +958,13 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row of this + * Retrieves the value of the designated columns in the current row of this * ResultSet object as a double in the Java programming language. * - * @param columnIndex the first column is 1, the second is 2, ... - * @return the column value; if the value is SQL NULL, the value returned + * @param columnIndex the first columns is 1, the second is 2, ... + * @return the columns value; if the value is SQL NULL, the value returned * is 0 - * @throws SQLException if there is no such column + * @throws SQLException if there is no such columns */ @Override public double getDouble(int columnIndex) throws SQLException { @@ -997,11 +984,11 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row of this + * Retrieves the value of the designated columns in the current row of this * ResultSet object as a double in the Java programming language. * - * @param columnName the SQL name of the column - * @return the column value; if the value is SQL NULL, the value returned + * @param columnName the SQL name of the columns + * @return the columns value; if the value is SQL NULL, the value returned * is 0 * @throws SQLException if the ResultSet object does not contain columnName */ @@ -1091,13 +1078,13 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row of this + * Retrieves the value of the designated columns in the current row of this * ResultSet object as a float in the Java programming language. * - * @param columnIndex the first column is 1, the second is 2, ... - * @return the column value; if the value is SQL NULL, the value returned + * @param columnIndex the first columns is 1, the second is 2, ... + * @return the columns value; if the value is SQL NULL, the value returned * is 0 - * @throws SQLException if there is no such column + * @throws SQLException if there is no such columns */ @Override public float getFloat(int columnIndex) throws SQLException { @@ -1117,11 +1104,11 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row of this + * Retrieves the value of the designated columns in the current row of this * ResultSet object as a float in the Java programming language. * - * @param columnName the SQL name of the column - * @return the column value; if the value is SQL NULL, the value returned is 0 + * @param columnName the SQL name of the columns + * @return the columns value; if the value is SQL NULL, the value returned is 0 * @throws SQLException if the ResultSet object does not contain columnName */ @Override @@ -1130,12 +1117,12 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row of this + * Retrieves the value of the designated columns in the current row of this * ResultSet object as an int in the Java programming language. * - * @param columnIndex the first column is 1, the second is 2, ... - * @return the column value; if the value is SQL NULL, the value returned is 0 - * @throws SQLException if there is no such column + * @param columnIndex the first columns is 1, the second is 2, ... + * @return the columns value; if the value is SQL NULL, the value returned is 0 + * @throws SQLException if there is no such columns */ @Override public int getInt(int columnIndex) throws SQLException { @@ -1169,11 +1156,11 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row of this + * Retrieves the value of the designated columns in the current row of this * ResultSet object as an int in the Java programming language. * - * @param columnName the SQL name of the column - * @return the column value; if the value is SQL NULL, the value returned is 0 + * @param columnName the SQL name of the columns + * @return the columns value; if the value is SQL NULL, the value returned is 0 * @throws SQLException if the ResultSet object does not contain columnName */ @Override @@ -1182,12 +1169,12 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row of this + * Retrieves the value of the designated columns in the current row of this * ResultSet object as a long in the Java programming language. * - * @param columnIndex the first column is 1, the second is 2, ... - * @return the column value; if the value is SQL NULL, the value returned is 0 - * @throws SQLException if there is no such column + * @param columnIndex the first columns is 1, the second is 2, ... + * @return the columns value; if the value is SQL NULL, the value returned is 0 + * @throws SQLException if there is no such columns */ @Override public long getLong(int columnIndex) throws SQLException { @@ -1221,11 +1208,11 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row of this + * Retrieves the value of the designated columns in the current row of this * ResultSet object as a long in the Java programming language. * - * @param columnName the SQL name of the column - * @return the column value; if the value is SQL NULL, the value returned + * @param columnName the SQL name of the columns + * @return the columns value; if the value is SQL NULL, the value returned * is 0 * @throws SQLException if the ResultSet object does not contain columnName */ @@ -1258,10 +1245,10 @@ public class MonetResultSet extends Mone private DatabaseMetaData dbmd = null; /** - * A private method to fetch the precision, scale, isNullable and isAutoincrement value for a fully qualified column. - * As md.getColumns() is an expensive method we call it only once per column + * A private method to fetch the precision, scale, isNullable and isAutoincrement value for a fully qualified columns. + * As md.getColumns() is an expensive method we call it only once per columns * and cache the precision, scale, isNullable and isAutoincrement values in the above array chaches. - * Also we only call md.getColumns() when we have a non empty schema name and table name and column name. + * Also we only call md.getColumns() when we have a non empty schema name and table name and columns name. */ private void fetchColumnInfo(int column) throws SQLException { @@ -1274,7 +1261,7 @@ public class MonetResultSet extends Mone _isNullable[column] = columnNullableUnknown; _isAutoincrement[column] = false; - // we can only call dbmd.getColumns() when we have a specific schema name and table name and column name + // we can only call dbmd.getColumns() when we have a specific schema name and table name and columns name String schName = getSchemaName(column); if (schName != null && !schName.isEmpty()) { String tblName = getTableName(column); @@ -1313,7 +1300,7 @@ public class MonetResultSet extends Mone /** * Returns the number of columns in this ResultSet object. * - * @returns the number of columns + * @return the number of columns */ @Override public int getColumnCount() { @@ -1321,16 +1308,16 @@ public class MonetResultSet extends Mone } /** - * Indicates whether the designated column is automatically numbered. + * Indicates whether the designated columns is automatically numbered. * - * @param column the first column is 1, the second is 2, ... + * @param column the first columns is 1, the second is 2, ... * @return true if so; false otherwise * @throws SQLException if a database access error occurs */ @Override public boolean isAutoIncrement(int column) throws SQLException { try { - if (_is_fetched[column] != true) { + if (!_is_fetched[column]) { fetchColumnInfo(column); } return _isAutoincrement[column]; @@ -1340,10 +1327,11 @@ public class MonetResultSet extends Mone } /** - * Indicates whether a column's case matters. + * Indicates whether a columns's case matters. * - * @param column the first column is 1, the second is 2, ... - * @returns true for all character string columns else false + * @param column the first columns is 1, the second is 2, ... + * @return true for all character string columns else false + * @throws SQLException if a database access error occurs */ @Override public boolean isCaseSensitive(int column) throws SQLException { @@ -1367,16 +1355,16 @@ public class MonetResultSet extends Mone } /** - * Indicates whether the designated column can be used in a + * Indicates whether the designated columns can be used in a * where clause. * It is unknown to me what kind ot columns they regard to, * as I think all columns are useable in a where clause. * Returning true for all here, for the time being. * Possible thought; maybe they want to know here if it's a - * real column existing in a table or not... + * real columns existing in a table or not... * - * @param column the first column is 1, the second is 2, ... - * @returns true + * @param column the first columns is 1, the second is 2, ... + * @return Always true */ @Override public boolean isSearchable(int column) { @@ -1384,14 +1372,14 @@ public class MonetResultSet extends Mone } /** - * Indicates whether the designated column is a cash value. + * Indicates whether the designated columns is a cash value. * From the MonetDB database perspective it is by definition * unknown whether the value is a currency, because there are * no currency datatypes such as MONEY. With this knowledge * we can always return false here. * - * @param column the first column is 1, the second is 2, ... - * @returns false + * @param column the first columns is 1, the second is 2, ... + * @return Always false */ @Override public boolean isCurrency(int column) { @@ -1399,11 +1387,11 @@ public class MonetResultSet extends Mone } /** - * Indicates whether values in the designated column are signed + * Indicates whether values in the designated columns are signed * numbers. * Within MonetDB all numeric types (except oid and ptr) are signed. * - * @param column the first column is 1, the second is 2, ... + * @param column the first columns is 1, the second is 2, ... * @return true if so; false otherwise */ @Override @@ -1439,13 +1427,13 @@ public class MonetResultSet extends Mone } /** - * Indicates the designated column's normal maximum width in + * Indicates the designated columns's normal maximum width in * characters. * - * @param column the first column is 1, the second is 2, ... + * @param column the first columns is 1, the second is 2, ... * @return the normal maximum number of characters allowed as the - * width of the designated column - * @throws SQLException if there is no such column + * width of the designated columns + * @throws SQLException if there is no such columns */ @Override public int getColumnDisplaySize(int column) throws SQLException { @@ -1461,9 +1449,9 @@ public class MonetResultSet extends Mone } /** - * Get the designated column's schema name. + * Get the designated columns's schema name. * - * @param column the first column is 1, the second is 2, ... + * @param column the first columns is 1, the second is 2, ... * @return schema name or "" if not applicable * @throws SQLException if a database access error occurs */ @@ -1485,9 +1473,9 @@ public class MonetResultSet extends Mone } /** - * Gets the designated column's table name. + * Gets the designated columns's table name. * - * @param column the first column is 1, the second is 2, ... + * @param column the first columns is 1, the second is 2, ... * @return table name or "" if not applicable */ @Override @@ -1508,19 +1496,19 @@ public class MonetResultSet extends Mone } /** - * Get the designated column's number of decimal digits. + * Get the designated columns's number of decimal digits. * This method is currently very expensive as it needs to * retrieve the information from the database using an SQL * query. * - * @param column the first column is 1, the second is 2, ... + * @param column the first columns is 1, the second is 2, ... * @return precision * @throws SQLException if a database access error occurs */ @Override public int getPrecision(int column) throws SQLException { try { - if (_is_fetched[column] != true) { + if (!_is_fetched[column]) { fetchColumnInfo(column); } if (_precision[column] == 0) { @@ -1582,19 +1570,19 @@ public class MonetResultSet extends Mone } /** - * Gets the designated column's number of digits to right of + * Gets the designated columns's number of digits to right of * the decimal point. This method is currently very * expensive as it needs to retrieve the information from * the database using an SQL query. * - * @param column the first column is 1, the second is 2, ... + * @param column the first columns is 1, the second is 2, ... * @return scale * @throws SQLException if a database access error occurs */ @Override public int getScale(int column) throws SQLException { try { - if (_is_fetched[column] != true) { + if (!_is_fetched[column]) { fetchColumnInfo(column); } return _scale[column]; @@ -1605,18 +1593,18 @@ public class MonetResultSet extends Mone /** * Indicates the nullability of values in the designated - * column. This method is currently very expensive as it + * columns. This method is currently very expensive as it * needs to retrieve the information from the database using * an SQL query. * - * @param column the first column is 1, the second is 2, ... - * @return the nullability status of the given column; one of columnNoNulls, columnNullable or columnNullableUnknown + * @param column the first columns is 1, the second is 2, ... + * @return the nullability status of the given columns; one of columnNoNulls, columnNullable or columnNullableUnknown * @throws SQLException if a database access error occurs */ @Override public int isNullable(int column) throws SQLException { try { - if (_is_fetched[column] != true) { + if (!_is_fetched[column]) { fetchColumnInfo(column); } return _isNullable[column]; @@ -1626,12 +1614,12 @@ public class MonetResultSet extends Mone } /** - * Gets the designated column's table's catalog name. + * Gets the designated columns's table's catalog name. * MonetDB does not support the catalog naming concept as in: catalog.schema.table naming scheme * - * @param column the first column is 1, the second is 2, ... + * @param column the first columns is 1, the second is 2, ... * @return the name of the catalog for the table in which the given - * column appears or "" if not applicable + * columns appears or "" if not applicable */ @Override public String getCatalogName(int column) throws SQLException { @@ -1640,11 +1628,11 @@ public class MonetResultSet extends Mone } /** - * Indicates whether the designated column is definitely not + * Indicates whether the designated columns is definitely not * writable. MonetDB does not support cursor updates, so * nothing is writable. * - * @param column the first column is 1, the second is 2, ... + * @param column the first columns is 1, the second is 2, ... * @return true if so; false otherwise */ @Override @@ -1654,9 +1642,9 @@ public class MonetResultSet extends Mone /** * Indicates whether it is possible for a write on the - * designated column to succeed. + * designated columns to succeed. * - * @param column the first column is 1, the second is 2, ... + * @param column the first columns is 1, the second is 2, ... * @return true if so; false otherwise */ @Override @@ -1665,10 +1653,10 @@ public class MonetResultSet extends Mone } /** - * Indicates whether a write on the designated column will + * Indicates whether a write on the designated columns will * definitely succeed. * - * @param column the first column is 1, the second is 2, ... + * @param column the first columns is 1, the second is 2, ... * @return true if so; false otherwise */ @Override @@ -1680,16 +1668,16 @@ public class MonetResultSet extends Mone * Returns the fully-qualified name of the Java class whose * instances are manufactured if the method * ResultSet.getObject is called to retrieve a value from - * the column. ResultSet.getObject may return a subclass of + * the columns. ResultSet.getObject may return a subclass of * the class returned by this method. * - * @param column the first column is 1, the second is 2, ... + * @param column the first columns is 1, the second is 2, ... * @return the fully-qualified name of the class in the Java * programming language that would be used by the method * ResultSet.getObject to retrieve the value in the - * specified column. This is the class name used for custom + * specified columns. This is the class name used for custom * mapping. - * @throws SQLException if there is no such column + * @throws SQLException if there is no such columns */ @Override public String getColumnClassName(int column) throws SQLException { @@ -1713,20 +1701,20 @@ public class MonetResultSet extends Mone if (type != null) { return type.getName(); } - throw new SQLException("column type mapping null: " + MonetDBType, "M0M03"); + throw new SQLException("columns type mapping null: " + MonetDBType, "M0M03"); } catch (IndexOutOfBoundsException e) { throw newSQLInvalidColumnIndexException(column); } } /** - * Gets the designated column's suggested title for use in + * Gets the designated columns's suggested title for use in * printouts and displays. This is currently equal to * getColumnName(). * - * @param column the first column is 1, the second is 2, ... - * @return the suggested column title - * @throws SQLException if there is no such column + * @param column the first columns is 1, the second is 2, ... + * @return the suggested columns title + * @throws SQLException if there is no such columns */ @Override public String getColumnLabel(int column) throws SQLException { @@ -1734,11 +1722,11 @@ public class MonetResultSet extends Mone } /** - * Gets the designated column's name + * Gets the designated columns's name * - * @param column the first column is 1, the second is 2, ... - * @return the column name - * @throws SQLException if there is no such column + * @param column the first columns is 1, the second is 2, ... + * @return the columns name + * @throws SQLException if there is no such columns */ @Override public String getColumnName(int column) throws SQLException { @@ -1750,11 +1738,11 @@ public class MonetResultSet extends Mone } /** - * Retrieves the designated column's SQL type. + * Retrieves the designated columns's SQL type. * - * @param column the first column is 1, the second is 2, ... + * @param column the first columns is 1, the second is 2, ... * @return SQL type from java.sql.Types - * @throws SQLException if there is no such column + * @throws SQLException if there is no such columns */ @Override public int getColumnType(int column) throws SQLException { @@ -1766,13 +1754,13 @@ public class MonetResultSet extends Mone } /** - * Retrieves the designated column's database-specific type name. + * Retrieves the designated columns's database-specific type name. * - * @param column the first column is 1, the second is 2, ... - * @return type name used by the database. If the column type is a + * @param column the first columns is 1, the second is 2, ... + * @return type name used by the database. If the columns type is a * user-defined type, then a fully-qualified type name is * returned. - * @throws SQLException if there is no such column + * @throws SQLException if there is no such columns */ @Override public String getColumnTypeName(int column) throws SQLException { @@ -1787,23 +1775,23 @@ public class MonetResultSet extends Mone } // end of getMetaData() /** - * Gets the value of the designated column in the current row of this + * Gets the value of the designated columns in the current row of this * ResultSet object as an Object in the Java programming language. * - * This method will return the value of the given column as a Java object. + * This method will return the value of the given columns as a Java object. * The type of the Java object will be the default Java object type - * corresponding to the column's SQL type, following the mapping for + * corresponding to the columns's SQL type, following the mapping for * built-in types specified in the JDBC specification. If the value is * an SQL NULL, the driver returns a Java null. * * This method may also be used to read database-specific abstract data * types. In the JDBC 2.0 API, the behavior of method getObject is extended - * to materialize data of SQL user-defined types. When a column contains a + * to materialize data of SQL user-defined types. When a columns contains a * structured or distinct value, the behavior of this method is as if it * were a call to: getObject(columnIndex, this.getStatement().getConnection().getTypeMap()). * - * @param columnIndex the first column is 1, the second is 2, ... - * @return a java.lang.Object holding the column value or null + * @param columnIndex the first columns is 1, the second is 2, ... + * @return a java.lang.Object holding the columns value or null * @throws SQLException if a database access error occurs */ @Override @@ -1911,7 +1899,7 @@ public class MonetResultSet extends Mone // if ("json".equals(MonetDBType)) { // There is no support for JSON in standard java class libraries. // Possibly we could use org.json.simple.JSONObject or other/faster libs - // javax.json.Json is not released yet (see https://json-processing-spec.java.net/) + // javax.json.JSON is not released yet (see https://json-processing-spec.java.net/) // see also https://github.com/fabienrenaud/java-json-benchmark // Note that it would make our JDBC driver dependent of an external jar // and we don't want that so simply return it as String object @@ -1940,7 +1928,7 @@ public class MonetResultSet extends Mone return getBytes(columnIndex); case Types.OTHER: default: - // When we get here the column type is a non-standard JDBC SQL type, possibly a User Defined Type. + // When we get here the columns type is a non-standard JDBC SQL type, possibly a User Defined Type. // Just call getObject(int, Map) for those rare cases. return getObject(columnIndex, this.getStatement().getConnection().getTypeMap()); } @@ -1948,20 +1936,20 @@ public class MonetResultSet extends Mone private boolean classImplementsSQLData(Class<?> cl) { Class<?>[] cls = cl.getInterfaces(); - for (int i = 0; i < cls.length; i++) { - if (cls[i] == SQLData.class) + for (Class<?> cl1 : cls) { + if (cl1 == SQLData.class) return true; } return false; } /** - * Gets the value of the designated column in the current row of this + * Gets the value of the designated columns in the current row of this * ResultSet object as an Object in the Java programming language. * - * This method will return the value of the given column as a Java object. + * This method will return the value of the given columns as a Java object. * The type of the Java object will be the default Java object type corresponding - * to the column's SQL type, following the mapping for built-in types specified + * to the columns's SQL type, following the mapping for built-in types specified * in the JDBC specification. * If the value is an SQL NULL, the driver returns a Java null. * @@ -1970,14 +1958,14 @@ public class MonetResultSet extends Mone * materialize data of SQL user-defined types. * * If Connection.getTypeMap does not throw a SQLFeatureNotSupportedException, then - * when a column contains a structured or distinct value, the behavior of this + * when a columns contains a structured or distinct value, the behavior of this * method is as if it were a call to: getObject(columnIndex, * this.getStatement().getConnection().getTypeMap()). * If Connection.getTypeMap does throw a SQLFeatureNotSupportedException, then * structured values are not supported, and distinct values are mapped to the * default Java class as determined by the underlying SQL type of the DISTINCT type. * - * @param columnIndex the first column is 1, the second is 2, ... + * @param columnIndex the first columns is 1, the second is 2, ... * @param map a java.util.Map object that contains the mapping from SQL * type names to classes in the Java programming language * @return an Object in the Java programming language representing the SQL @@ -2017,17 +2005,17 @@ public class MonetResultSet extends Mone } else if (type == BigDecimal.class) { return getBigDecimal(columnIndex); } else if (type == Boolean.class) { - return Boolean.valueOf(getBoolean(columnIndex)); + return getBoolean(columnIndex); } else if (type == Short.class) { - return Short.valueOf(getShort(columnIndex)); + return getShort(columnIndex); } else if (type == Integer.class) { - return Integer.valueOf(getInt(columnIndex)); + return getInt(columnIndex); } else if (type == Long.class) { - return Long.valueOf(getLong(columnIndex)); + return getLong(columnIndex); } else if (type == Float.class) { - return Float.valueOf(getFloat(columnIndex)); + return getFloat(columnIndex); } else if (type == Double.class) { - return Double.valueOf(getDouble(columnIndex)); + return getDouble(columnIndex); } else if (type == byte[].class) { return getBytes(columnIndex); } else if (type == java.sql.Date.class) { @@ -2046,16 +2034,8 @@ public class MonetResultSet extends Mone Constructor<? extends SQLData> ctor = ((Class)type).getConstructor(); x = ctor.newInstance(); - } catch (NoSuchMethodException nsme) { + } catch (NoSuchMethodException | InstantiationException | IllegalAccessException | SecurityException | InvocationTargetException nsme) { throw new SQLException(nsme.getMessage(), "M0M27"); - } catch (InstantiationException ie) { - throw new SQLException(ie.getMessage(), "M0M27"); - } catch (IllegalAccessException iae) { - throw new SQLException(iae.getMessage(), "M0M27"); - } catch (InvocationTargetException ite) { - throw new SQLException(ite.getMessage(), "M0M27"); - } catch (SecurityException se) { - throw new SQLException(se.getMessage(), "M0M27"); } final int colnum = columnIndex; final boolean valwasnull = wasNull(); @@ -2203,9 +2183,9 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row + * Retrieves the value of the designated columns in the current row * of this ResultSet object and will convert from the SQL type of - * the column to the requested Java data type, if the conversion is + * the columns to the requested Java data type, if the conversion is * supported. If the conversion is not supported or null is * specified for the type, a SQLException is thrown. * @@ -2214,10 +2194,10 @@ public class MonetResultSet extends Mone * SQL types to a Java type which implements SQLData, or Struct. * Additional conversions may be supported and are vendor defined. * - * @param i the first column is 1, the second is 2, ... + * @param i the first columns is 1, the second is 2, ... * @param type Class representing the Java data type to convert the - * designated column to - * @return an instance of type holding the column value + * designated columns to + * @return an instance of type holding the columns value * @throws SQLException if conversion is not supported, type is * null or another error occurs. The getCause() method of * the exception may provide a more detailed exception, for @@ -2232,18 +2212,18 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row + * Retrieves the value of the designated columns in the current row * of this ResultSet object and will convert from the SQL type of - * the column to the requested Java data type, if the conversion is + * the columns to the requested Java data type, if the conversion is * supported. If the conversion is not supported or null is * specified for the type, a SQLException is thrown. * - * @param columnLabel the label for the column specified with the + * @param columnLabel the label for the columns specified with the * SQL AS clause. If the SQL AS clause was not specified, - * then the label is the name of the column + * then the label is the name of the columns * @param type Class representing the Java data type to convert the - * designated column to - * @return an instance of type holding the column value + * designated columns to + * @return an instance of type holding the columns value * @throws SQLException if conversion is not supported, type is * null or another error occurs. The getCause() method of * the exception may provide a more detailed exception, for @@ -2314,20 +2294,20 @@ public class MonetResultSet extends Mone } /** - * Gets the value of the designated column in the current row of this + * Gets the value of the designated columns in the current row of this * ResultSet object as an Object in the Java programming language. * - * This method will return the value of the given column as a Java object. + * This method will return the value of the given columns as a Java object. * The type of the Java object will be the default Java object type - * corresponding to the column's SQL type, following the mapping for + * corresponding to the columns's SQL type, following the mapping for * built-in types specified in the JDBC specification. If the value is an * SQL NULL, the driver returns a Java null. * * This method may also be used to read database-specific abstract data * types. * - * @param columnName the SQL name of the column - * @return a java.lang.Object holding the column value + * @param columnName the SQL name of the columns + * @return a java.lang.Object holding the columns value * @throws SQLException if a database access error occurs */ @Override @@ -2336,15 +2316,15 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row of this + * Retrieves the value of the designated columns in the current row of this * ResultSet object as an Object in the Java programming language. If the * value is an SQL NULL, the driver returns a Java null. This method uses * the specified Map object for custom mapping if appropriate. * - * @param colName the name of the column from which to retrieve the value + * @param colName the name of the columns from which to retrieve the value * @param map a java.util.Map object that contains the mapping from SQL * type names to classes in the Java programming language - * @return an Object representing the SQL value in the specified column + * @return an Object representing the SQL value in the specified columns * @throws SQLException if a database access error occurs */ @Override @@ -2374,14 +2354,14 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row + * Retrieves the value of the designated columns in the current row * of this ResultSet object as a java.sql.RowId object in the Java * programming language. * - * @param columnIndex the first column is 1, the second is 2, ... - * @return the column value; if the value is SQL NULL, the value returned + * @param columnIndex the first columns is 1, the second is 2, ... + * @return the columns value; if the value is SQL NULL, the value returned * is null - * @throws SQLException if there is no such column + * @throws SQLException if there is no such columns * @throws SQLFeatureNotSupportedException the JDBC driver does * not support this method */ @@ -2391,12 +2371,12 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row + * Retrieves the value of the designated columns in the current row * of this ResultSet object as a java.sql.RowId object in the Java * programming language. * - * @param columnName the SQL name of the column - * @return the column value; if the value is SQL NULL, the value returned + * @param columnName the SQL name of the columns + * @return the columns value; if the value is SQL NULL, the value returned * is null * @throws SQLException if the ResultSet object does not contain columnName * @throws SQLFeatureNotSupportedException the JDBC driver does @@ -2408,13 +2388,13 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row of this + * Retrieves the value of the designated columns in the current row of this * ResultSet object as a short in the Java programming language. * - * @param columnIndex the first column is 1, the second is 2, ... - * @return the column value; if the value is SQL NULL, the value returned + * @param columnIndex the first columns is 1, the second is 2, ... + * @return the columns value; if the value is SQL NULL, the value returned * is 0 - * @throws SQLException if there is no such column + * @throws SQLException if there is no such columns */ @Override public short getShort(int columnIndex) throws SQLException { @@ -2434,11 +2414,11 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row of this + * Retrieves the value of the designated columns in the current row of this * ResultSet object as a short in the Java programming language. * - * @param columnName the SQL name of the column - * @return the column value; if the value is SQL NULL, the value returned + * @param columnName the SQL name of the columns + * @return the columns value; if the value is SQL NULL, the value returned * is 0 * @throws SQLException if the ResultSet object does not contain columnName */ @@ -2461,13 +2441,13 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row of this + * Retrieves the value of the designated columns in the current row of this * ResultSet object as a String in the Java programming language. * - * @param columnIndex the first column is 1, the second is 2, ... - * @return the column value; if the value is SQL NULL, the value returned + * @param columnIndex the first columns is 1, the second is 2, ... + * @return the columns value; if the value is SQL NULL, the value returned * is null - * @throws SQLException if there is no such column + * @throws SQLException if there is no such columns */ @Override public String getString(int columnIndex) throws SQLException { @@ -2485,11 +2465,11 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row of this + * Retrieves the value of the designated columns in the current row of this * ResultSet object as a String in the Java programming language. * - * @param columnName the SQL name of the column - * @return the column value; if the value is SQL NULL, the value returned + * @param columnName the SQL name of the columns + * @return the columns value; if the value is SQL NULL, the value returned * is null * @throws SQLException if the ResultSet object does not contain columnName */ @@ -2499,15 +2479,15 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row + * Retrieves the value of the designated columns in the current row * of this ResultSet object as a String in the Java programming * language. It is intended for use when accessing NCHAR,NVARCHAR * and LONGNVARCHAR columns. * - * @param columnIndex the first column is 1, the second is 2, ... - * @return the column value; if the value is SQL NULL, the value returned + * @param columnIndex the first columns is 1, the second is 2, ... + * @return the columns value; if the value is SQL NULL, the value returned * is null - * @throws SQLException if there is no such column + * @throws SQLException if there is no such columns * @throws SQLFeatureNotSupportedException the JDBC driver does * not support this method */ @@ -2517,13 +2497,13 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row + * Retrieves the value of the designated columns in the current row * of this ResultSet object as a String in the Java programming * language. It is intended for use when accessing NCHAR,NVARCHAR * and LONGNVARCHAR columns. * - * @param columnName the SQL name of the column - * @return the column value; if the value is SQL NULL, the value returned + * @param columnName the SQL name of the columns + * @return the columns value; if the value is SQL NULL, the value returned * is null * @throws SQLException if the ResultSet object does not contain columnName * @throws SQLFeatureNotSupportedException the JDBC driver does @@ -2535,11 +2515,11 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row + * Retrieves the value of the designated columns in the current row * of this ResultSet as a java.sql.SQLXML object in the Java * programming language. * - * @param i the first column is 1, the second is 2, ... + * @param i the first columns is 1, the second is 2, ... * @return a SQLXML object that maps an SQL XML value * @throws SQLException if a database access error occurs * @throws SQLFeatureNotSupportedException the JDBC driver does @@ -2551,13 +2531,13 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row + * Retrieves the value of the designated columns in the current row * of this ResultSet as a java.sql.SQLXML object in the Java * programming language. * - * @param colName the label for the column specified with the SQL AS + * @param colName the label for the columns specified with the SQL AS * clause. If the SQL AS clause was not specified, then the - * label is the name of the column + * label is the name of the columns * @return a SQLXML object that maps an SQL XML value * @throws SQLException if a database access error occurs * @throws SQLFeatureNotSupportedException the JDBC driver does @@ -2581,12 +2561,12 @@ public class MonetResultSet extends Mone * LONGVARCHAR an attempt is made to parse the date according to the * given type. The given Calender object is filled with the parsed * data. Optional fractional seconds (nanos) are returned by this - * method. If the underlying type of the column is none of the + * method. If the underlying type of the columns is none of the * mentioned six, January 1st 1970 0:00:00 GMT is returned.<br /> * The dates are parsed with the given Calendar. * * @param cal the Calendar to use/fill when parsing the date/time - * @param columnIndex the column to parse + * @param columnIndex the columns to parse * @param type the corresponding java.sql.Types type of the calling * function * @return the fractional seconds (nanos) or -1 if the value is NULL @@ -2636,7 +2616,7 @@ public class MonetResultSet extends Mone } } - java.util.Date pdate = null; + java.util.Date pdate; ParsePosition ppos = new ParsePosition(0); switch(JdbcType) { case Types.DATE: @@ -2739,12 +2719,12 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row of this + * Retrieves the value of the designated columns in the current row of this * ResultSet object as a java.sql.Date object in the Java programming * language. * - * @param columnIndex the first column is 1, the second is 2, ... - * @return the column value; if the value is SQL NULL, the value returned + * @param columnIndex the first columns is 1, the second is 2, ... + * @return the columns value; if the value is SQL NULL, the value returned * is null * @throws SQLException if a database access error occurs * @see #getDate(int col, Calendar cal) @@ -2755,15 +2735,15 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row of this + * Retrieves the value of the designated columns in the current row of this * ResultSet object as a java.sql.Date object in the Java programming * language. This method uses the given calendar to construct an appropriate * millisecond value for the date if the underlying database does not store * timezone information. * - * @param columnIndex the first column is 1, the second is 2, ... + * @param columnIndex the first columns is 1, the second is 2, ... * @param cal the java.util.Calendar object to use in constructing the date - * @return the column value; if the value is SQL NULL, the value returned + * @return the columns value; if the value is SQL NULL, the value returned * is null * @throws SQLException if a database access error occurs */ @@ -2776,13 +2756,13 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row of this + * Retrieves the value of the designated columns in the current row of this * ResultSet object as a java.sql.Date object in the Java programming * language. * - * @param columnName the SQL name of the column from which to retrieve the + * @param columnName the SQL name of the columns from which to retrieve the * value - * @return the column value; if the value is SQL NULL, the value returned + * @return the columns value; if the value is SQL NULL, the value returned * is null * @throws SQLException if a database access error occurs */ @@ -2792,16 +2772,16 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row of this + * Retrieves the value of the designated columns in the current row of this * ResultSet object as a java.sql.Date object in the Java programming * language. This method uses the given calendar to construct an appropriate * millisecond value for the date if the underlying database does not store * timezone information. * - * @param columnName the SQL name of the column from which to retrieve the + * @param columnName the SQL name of the columns from which to retrieve the * value * @param cal the java.util.Calendar object to use in constructing the date - * @return the column value; if the value is SQL NULL, the value returned + * @return the columns value; if the value is SQL NULL, the value returned * is null * @throws SQLException if a database access error occurs */ @@ -2813,12 +2793,12 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row of this + * Retrieves the value of the designated columns in the current row of this * ResultSet object as a java.sql.Time object in the Java programming * language. * - * @param columnIndex the first column is 1, the second is 2, ... - * @return the column value; if the value is SQL NULL, the value returned + * @param columnIndex the first columns is 1, the second is 2, ... + * @return the columns value; if the value is SQL NULL, the value returned * is null * @throws SQLException if a database access error occurs */ @@ -2828,16 +2808,16 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row of + * Retrieves the value of the designated columns in the current row of * this ResultSet object as a java.sql.Time object in the Java programming * language. This method uses the given calendar to construct an appropriate * millisecond value for the time if the underlying database does not store * timezone information. * - * @param columnIndex the first column is 1, the second is 2, ... + * @param columnIndex the first columns is 1, the second is 2, ... * @param cal the java.util.Calendar object to use in constructing the * timestamp - * @return the column value as a java.sql.Timestamp object; if the value is + * @return the columns value as a java.sql.Timestamp object; if the value is * SQL NULL, the value returned is null in the Java programming * language * @throws SQLException if a database access error occurs @@ -2851,12 +2831,12 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row of this + * Retrieves the value of the designated columns in the current row of this * ResultSet object as a java.sql.Time object in the Java programming * language. * - * @param columnName the SQL name of the column - * @return the column value; if the value is SQL NULL, the value returned + * @param columnName the SQL name of the columns + * @return the columns value; if the value is SQL NULL, the value returned * is null * @throws SQLException if a database access error occurs */ @@ -2866,16 +2846,16 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row of + * Retrieves the value of the designated columns in the current row of * this ResultSet object as a java.sql.Time object in the Java programming * language. This method uses the given calendar to construct an appropriate * millisecond value for the time if the underlying database does not store * timezone information. * - * @param columnName the SQL name of the column + * @param columnName the SQL name of the columns * @param cal the java.util.Calendar object to use in constructing the * timestamp - * @return the column value as a java.sql.Timestamp object; if the value is + * @return the columns value as a java.sql.Timestamp object; if the value is * SQL NULL, the value returned is null in the Java programming * language * @throws SQLException if a database access error occurs @@ -2888,12 +2868,12 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row of this + * Retrieves the value of the designated columns in the current row of this * ResultSet object as a java.sql.Timestamp object in the Java programming * language. * - * @param columnIndex the first column is 1, the second is 2, ... - * @return the column value; if the value is SQL NULL, the value returned + * @param columnIndex the first columns is 1, the second is 2, ... + * @return the columns value; if the value is SQL NULL, the value returned * is null * @throws SQLException if a database access error occurs */ @@ -2903,16 +2883,16 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row of this + * Retrieves the value of the designated columns in the current row of this * ResultSet object as a java.sql.Timestamp object in the Java programming * language. This method uses the given calendar to construct an appropriate * millisecond value for the timestamp if the underlying database does not * store timezone information. * - * @param columnIndex the first column is 1, the second is 2, ... + * @param columnIndex the first columns is 1, the second is 2, ... * @param cal the java.util.Calendar object to use in constructing the * timestamp - * @return the column value as a java.sql.Timestamp object; if the value is + * @return the columns value as a java.sql.Timestamp object; if the value is * SQL NULL, the value returned is null in the Java programming * language * @throws SQLException if a database access error occurs @@ -2931,12 +2911,12 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row of this + * Retrieves the value of the designated columns in the current row of this * ResultSet object as a java.sql.Timestamp object in the Java programming * language. * - * @param columnName the SQL name of the column - * @return the column value; if the value is SQL NULL, the value returned + * @param columnName the SQL name of the columns + * @return the columns value; if the value is SQL NULL, the value returned * is null * @throws SQLException if a database access error occurs */ @@ -2946,16 +2926,16 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row of this + * Retrieves the value of the designated columns in the current row of this * ResultSet object as a java.sql.Timestamp object in the Java programming * language. This method uses the given calendar to construct an appropriate * millisecond value for the timestamp if the underlying database does not * store timezone information. * - * @param columnName the SQL name of the column + * @param columnName the SQL name of the columns * @param cal the java.util.Calendar object to use in constructing the * timestamp - * @return the column value as a java.sql.Timestamp object; if the value is + * @return the columns value as a java.sql.Timestamp object; if the value is * SQL NULL, the value returned is null in the Java programming * language * @throws SQLException if a database access error occurs @@ -2980,13 +2960,13 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row + * Retrieves the value of the designated columns in the current row * of this ResultSet object as a java.net.URL object in the Java * programming language. * - * @param columnIndex the index of the column 1 is the first, + * @param columnIndex the index of the columns 1 is the first, * 2 is the second,... - * @return the column value as a java.net.URL object; if the value + * @return the columns value as a java.net.URL object; if the value * is SQL NULL, the value returned is null in the Java * programming language * @throws SQLException if a database access error occurs, or if a @@ -3012,12 +2992,12 @@ public class MonetResultSet extends Mone } /** - * Retrieves the value of the designated column in the current row + * Retrieves the value of the designated columns in the current row * of this ResultSet object as a java.net.URL object in the Java * programming language. * - * @param columnName the SQL name of the column - * @return the column value as a java.net.URL object; if the value + * @param columnName the SQL name of the columns + * @return the columns value as a java.net.URL object; if the value * is SQL NULL, the value returned is null in the Java * programming language * @throws SQLException if a database access error occurs, or if a @@ -3695,12 +3675,12 @@ public class MonetResultSet extends Mone // Chapter 14.2.3.3 Sun JDBC 3.0 Specification /** - * Reports whether the last column read had a value of SQL NULL. Note that - * you must first call one of the getter methods on a column to try to read + * Reports whether the last columns read had a value of SQL NULL. Note that + * you must first call one of the getter methods on a columns to try to read * its value and then call the method wasNull to see if the value read was * SQL NULL. * - * @return true if the last column value read was SQL NULL and false + * @return true if the last columns value read was SQL NULL and false * otherwise */ @Override @@ -3727,14 +3707,14 @@ public class MonetResultSet extends Mone } /** - * Small helper method that formats the "Invalid Column Index number ..." message + * Small helper method that formats the "Invalid QueryResultSetColumn Index number ..." message * and creates a new SQLException object whose SQLState is set to "M1M05". * - * @param colIdx the column index number + * @param colIdx the columns index number * @return a new created SQLException object with SQLState M1M05 */ public final static SQLException newSQLInvalidColumnIndexException(int colIdx) { - return new SQLException("Invalid Column Index number: " + colIdx, "M1M05"); + return new SQLException("Invalid QueryResultSetColumn Index number: " + colIdx, "M1M05"); } /**
--- a/src/main/java/nl/cwi/monetdb/jdbc/MonetStatement.java +++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetStatement.java @@ -74,7 +74,7 @@ public class MonetStatement extends Mone private int resultSetConcurrency = ResultSet.CONCUR_READ_ONLY; /** A List to hold all queries of a batch */ - private List<String> batch = new ArrayList<String>(); + private List<String> batch = new ArrayList<>(); /** @@ -105,13 +105,13 @@ public class MonetStatement extends Mone // check our limits, and generate warnings as appropriate if (resultSetConcurrency != ResultSet.CONCUR_READ_ONLY) { addWarning("No concurrency mode other then read only is supported, continuing with concurrency level READ_ONLY", "01M13"); - resultSetConcurrency = ResultSet.CONCUR_READ_ONLY; + this.resultSetConcurrency = ResultSet.CONCUR_READ_ONLY; } // check type for supported mode if (resultSetType == ResultSet.TYPE_SCROLL_SENSITIVE) { addWarning("Change sensitive scrolling ResultSet objects are not supported, continuing with a change non-sensitive scrollable cursor.", "01M14"); - resultSetType = ResultSet.TYPE_SCROLL_INSENSITIVE; + this.resultSetType = ResultSet.TYPE_SCROLL_INSENSITIVE; } // check type for supported holdability @@ -413,8 +413,8 @@ public class MonetStatement extends Mone * getResultSet or getUpdateCount to retrieve the result, and * getMoreResults to move to any subsequent result(s). * - * MonetDB only supports returing the generated key for one column, - * which will be the first column that has a serial. Hence, this + * MonetDB only supports returing the generated key for one columns, + * which will be the first columns that has a serial. Hence, this * method cannot work as required and the driver will fall back to * executing with request to the database to return the generated * key, if any. @@ -427,7 +427,7 @@ public class MonetStatement extends Mone * it is an update count or there are no results * @throws SQLException if a database access error occurs or the * elements in the int array passed to this method are not - * valid column indexes + * valid columns indexes */ @Override public boolean execute(String sql, int[] columnIndexes) @@ -457,8 +457,8 @@ public class MonetStatement extends Mone * getResultSet or getUpdateCount to retrieve the result, and * getMoreResults to move to any subsequent result(s). * - * MonetDB only supports returing the generated key for one column, - * which will be the first column that has a serial. Hence, this + * MonetDB only supports returing the generated key for one columns, + * which will be the first columns that has a serial. Hence, this * method cannot work as required and the driver will fall back to * executing with request to the database to return the generated * key, if any. @@ -471,7 +471,7 @@ public class MonetStatement extends Mone * it is an update count or there are no more results * @throws SQLException if a database access error occurs or the * elements of the String array passed to this method are - * not valid column names + * not valid columns names */ @Override public boolean execute(String sql, String[] columnNames) @@ -527,7 +527,7 @@ public class MonetStatement extends Mone */ @Override public ResultSet executeQuery(String sql) throws SQLException { - if (execute(sql) != true) + if (!execute(sql)) throw new SQLException("Query did not produce a result set", "M1M19"); return getResultSet(); @@ -547,7 +547,7 @@ public class MonetStatement extends Mone */ @Override public int executeUpdate(String sql) throws SQLException { - if (execute(sql) != false) + if (execute(sql)) throw new SQLException("Query produced a result set", "M1M17"); return getUpdateCount(); @@ -581,7 +581,7 @@ public class MonetStatement extends Mone /* MonetDB has no way to disable this, so just do the normal * thing ;) */ - if (execute(sql) != false) + if (execute(sql)) throw new SQLException("Query produced a result set", "M1M17"); return getUpdateCount(); @@ -593,22 +593,22 @@ public class MonetStatement extends Mone * available for retrieval. The driver will ignore the array if the * SQL statement is not an INSERT statement. * - * MonetDB only supports returing the generated key for one column, - * which will be the first column that has a serial. Hence, this + * MonetDB only supports returing the generated key for one columns, + * which will be the first columns that has a serial. Hence, this * method cannot work as required and the driver will fall back to * executing with request to the database to return the generated * key, if any. * * @param sql an SQL INSERT, UPDATE or DELETE statement or an SQL * statement that returns nothing, such as an SQL DDL statement - * @param columnIndexes an array of column indexes indicating the + * @param columnIndexes an array of columns indexes indicating the * columns that should be returned from the inserted row * @return either the row count for INSERT, UPDATE, or DELETE * statements, or 0 for SQL statements that return nothing * @throws SQLException if a database access error occurs, the SQL * statement returns a ResultSet object, or the second * argument supplied to this method is not an int array - * whose elements are valid column indexes + * whose elements are valid columns indexes */ @Override public int executeUpdate(String sql, int[] columnIndexes) @@ -624,8 +624,8 @@ public class MonetStatement extends Mone * available for retrieval. The driver will ignore the array if the * SQL statement is not an INSERT statement. * - * MonetDB only supports returing the generated key for one column, - * which will be the first column that has a serial. Hence, this + * MonetDB only supports returing the generated key for one columns, + * which will be the first columns that has a serial. Hence, this * method cannot work as required and the driver will fall back to * executing with request to the database to return the generated * key, if any. @@ -639,7 +639,7 @@ public class MonetStatement extends Mone * @throws SQLException if a database access error occurs, the SQL * statement returns a ResultSet object, or the second * argument supplied to this method is not a String array - * whose elements are valid column names + * whose elements are valid columns names */ @Override public int executeUpdate(String sql, String[] columnNames) @@ -731,7 +731,7 @@ public class MonetStatement extends Mone /** * Retrieves the maximum number of bytes that can be returned for - * character and binary column values in a ResultSet object produced + * character and binary columns values in a ResultSet object produced * by this Statement object. This limit applies only to BINARY, * VARBINARY, LONGVARBINARY, CHAR, VARCHAR, and LONGVARCHAR * columns. If the limit is exceeded, the excess data is silently @@ -740,7 +740,7 @@ public class MonetStatement extends Mone * The MonetDB JDBC driver currently doesn't support limiting * fieldsizes, and hence always return 0 (unlimited). * - * @return the current column size limit for columns storing + * @return the current columns size limit for columns storing * character and binary values; zero means there is no limit * @throws SQLException if a database access error occurs */ @@ -814,11 +814,7 @@ public class MonetStatement extends Mone // we default to keep current result, which requires no action header = lastResponseList.getNextResponse(); - if (header instanceof MonetConnection.ResultSetResponse) { - return true; - } else { - return false; - } + return header instanceof MonetConnection.ResultSetResponse; } /** @@ -1053,7 +1049,7 @@ public class MonetStatement extends Mone /** * Sets the limit for the maximum number of bytes in a ResultSet - * column storing character or binary values to the given number of + * columns storing character or binary values to the given number of * bytes. This limit applies only to BINARY, VARBINARY, * LONGVARBINARY, CHAR, VARCHAR, and LONGVARCHAR fields. If the * limit is exceeded, the excess data is silently discarded. For @@ -1063,7 +1059,7 @@ public class MonetStatement extends Mone * driver does not emulate it either, since it doesn't really lead * to memory reduction. * - * @param max the new column size limit in bytes; zero means there + * @param max the new columns size limit in bytes; zero means there * is no limit * @throws SQLException if a database access error occurs or the * condition max >= 0 is not satisfied @@ -1291,9 +1287,7 @@ final class MonetVirtualResultSet extend // see if we have the row if (row < 1 || row > tupleCount) return false; - for (int i = 0; i < results[row - 1].length; i++) { - tlp.values[i] = results[row - 1][i]; - } + System.arraycopy(results[row - 1], 0, tlp.values, 0, results[row - 1].length); return true; }
--- a/src/main/java/nl/cwi/monetdb/mcl/net/MapiSocket.java +++ b/src/main/java/nl/cwi/monetdb/mcl/net/MapiSocket.java @@ -284,8 +284,8 @@ public final class MapiSocket { ); // read monet response till prompt - List<String> redirects = new ArrayList<String>(); - List<String> warns = new ArrayList<String>(); + List<String> redirects = new ArrayList<>(); + List<String> warns = new ArrayList<>(); String err = "", tmp; int lineType; do { @@ -301,7 +301,7 @@ public final class MapiSocket { redirects.add(tmp.substring(1)); } } while (lineType != BufferedMCLReader.PROMPT); - if (err != "") { + if (!err.equals("")) { close(); throw new MCLException(err.trim()); } @@ -316,7 +316,7 @@ public final class MapiSocket { // "mapi:merovingian://proxy?arg=value&..." // note that the extra arguments must be obeyed in both // cases - String suri = redirects.get(0).toString(); + String suri = redirects.get(0); if (!suri.startsWith("mapi:")) throw new MCLException("unsupported redirect: " + suri); @@ -330,74 +330,82 @@ public final class MapiSocket { tmp = u.getQuery(); if (tmp != null) { String args[] = tmp.split("&"); - for (int i = 0; i < args.length; i++) { - int pos = args[i].indexOf("="); + for (String arg : args) { + int pos = arg.indexOf("="); if (pos > 0) { - tmp = args[i].substring(0, pos); - if (tmp.equals("database")) { - tmp = args[i].substring(pos + 1); - if (!tmp.equals(database)) { - warns.add("redirect points to different " + - "database: " + tmp); - setDatabase(tmp); - } - } else if (tmp.equals("language")) { - tmp = args[i].substring(pos + 1); - warns.add("redirect specifies use of different language: " + tmp); - setLanguage(tmp); - } else if (tmp.equals("user")) { - tmp = args[i].substring(pos + 1); - if (!tmp.equals(user)) - warns.add("ignoring different username '" + tmp + "' set by " + - "redirect, what are the security implications?"); - } else if (tmp.equals("password")) { - warns.add("ignoring different password set by redirect, " + - "what are the security implications?"); - } else { - warns.add("ignoring unknown argument '" + tmp + "' from redirect"); + tmp = arg.substring(0, pos); + switch (tmp) { + case "database": + tmp = arg.substring(pos + 1); + if (!tmp.equals(database)) { + warns.add("redirect points to different " + + "database: " + tmp); + setDatabase(tmp); + } + break; + case "language": + tmp = arg.substring(pos + 1); + warns.add("redirect specifies use of different language: " + tmp); + setLanguage(tmp); + break; + case "user": + tmp = arg.substring(pos + 1); + if (!tmp.equals(user)) + warns.add("ignoring different username '" + tmp + "' set by " + + "redirect, what are the security implications?"); + break; + case "password": + warns.add("ignoring different password set by redirect, " + + "what are the security implications?"); + break; + default: + warns.add("ignoring unknown argument '" + tmp + "' from redirect"); + break; } } else { - warns.add("ignoring illegal argument from redirect: " + - args[i]); + warns.add("ignoring illegal argument from redirect: " + arg); } } } - if (u.getScheme().equals("monetdb")) { - // this is a redirect to another (monetdb) server, - // which means a full reconnect - // avoid the debug log being closed - if (debug) { - debug = false; - close(); - debug = true; - } else { - close(); - } - tmp = u.getPath(); - if (tmp != null && tmp.length() != 0) { - tmp = tmp.substring(1).trim(); - if (!tmp.isEmpty() && !tmp.equals(database)) { - warns.add("redirect points to different " + - "database: " + tmp); - setDatabase(tmp); + switch (u.getScheme()) { + case "monetdb": + // this is a redirect to another (monetdb) server, + // which means a full reconnect + // avoid the debug log being closed + if (debug) { + debug = false; + close(); + debug = true; + } else { + close(); } - } - int p = u.getPort(); - warns.addAll(connect(u.getHost(), p == -1 ? port : p, - user, pass, true)); - warns.add("Redirect by " + host + ":" + port + " to " + suri); - } else if (u.getScheme().equals("merovingian")) { - // reuse this connection to inline connect to the - // right database that Merovingian proxies for us - warns.addAll(connect(host, port, user, pass, false)); - } else { - throw new MCLException("unsupported scheme in redirect: " + suri); + tmp = u.getPath(); + if (tmp != null && tmp.length() != 0) { + tmp = tmp.substring(1).trim(); + if (!tmp.isEmpty() && !tmp.equals(database)) { + warns.add("redirect points to different " + + "database: " + tmp); + setDatabase(tmp); + } + } + int p = u.getPort(); + warns.addAll(connect(u.getHost(), p == -1 ? port : p, + user, pass, true)); + warns.add("Redirect by " + host + ":" + port + " to " + suri); + break; + case "merovingian": + // reuse this connection to inline connect to the + // right database that Merovingian proxies for us + warns.addAll(connect(host, port, user, pass, false)); + break; + default: + throw new MCLException("unsupported scheme in redirect: " + suri); } } else { StringBuilder msg = new StringBuilder("The server sent a redirect for this connection:"); for (String it : redirects) { - msg.append(" [" + it + "]"); + msg.append(" [").append(it).append("]"); } throw new MCLException(msg.toString()); } @@ -453,20 +461,25 @@ public final class MapiSocket { // challenge after the byte-order /* NOTE: Java doesn't support RIPEMD160 :( */ - if (chaltok[5].equals("SHA512")) { - algo = "SHA-512"; - } else if (chaltok[5].equals("SHA384")) { - algo = "SHA-384"; - } else if (chaltok[5].equals("SHA256")) { - algo = "SHA-256"; + switch (chaltok[5]) { + case "SHA512": + algo = "SHA-512"; + break; + case "SHA384": + algo = "SHA-384"; + break; + case "SHA256": + algo = "SHA-256"; /* NOTE: Java doesn't support SHA-224 */ - } else if (chaltok[5].equals("SHA1")) { - algo = "SHA-1"; - } else if (chaltok[5].equals("MD5")) { - algo = "MD5"; - } else { - throw new MCLException("Unsupported password hash: " + - chaltok[5]); + break; + case "SHA1": + algo = "SHA-1"; + break; + case "MD5": + algo = "MD5"; + break; + default: + throw new MCLException("Unsupported password hash: " + chaltok[5]); } try { @@ -474,9 +487,7 @@ public final class MapiSocket { md.update(password.getBytes("UTF-8")); byte[] digest = md.digest(); password = toHex(digest); - } catch (NoSuchAlgorithmException e) { - throw new AssertionError("internal error: " + e.toString()); - } catch (UnsupportedEncodingException e) { + } catch (NoSuchAlgorithmException | UnsupportedEncodingException e) { throw new AssertionError("internal error: " + e.toString()); } @@ -491,7 +502,7 @@ public final class MapiSocket { // proto 8, the byte-order of the blocks is always little // endian because most machines today are. String hashes = (hash == null ? chaltok[3] : hash); - Set<String> hashesSet = new HashSet<String>(Arrays.asList(hashes.toUpperCase().split("[, ]"))); + Set<String> hashesSet = new HashSet<>(Arrays.asList(hashes.toUpperCase().split("[, ]"))); // if we deal with merovingian, mask our credentials if (servert.equals("merovingian") && !language.equals("control")) { @@ -499,7 +510,6 @@ public final class MapiSocket { password = "merovingian"; } String pwhash; - algo = null; if (hashesSet.contains("SHA512")) { algo = "SHA-512"; @@ -519,27 +529,26 @@ public final class MapiSocket { } else { throw new MCLException("no supported password hashes in " + hashes); } - if (algo != null) { - try { - MessageDigest md = MessageDigest.getInstance(algo); - md.update(password.getBytes("UTF-8")); - md.update(challenge.getBytes("UTF-8")); - byte[] digest = md.digest(); - pwhash += toHex(digest); - } catch (NoSuchAlgorithmException e) { - throw new AssertionError("internal error: " + e.toString()); - } catch (UnsupportedEncodingException e) { - throw new AssertionError("internal error: " + e.toString()); - } + try { + MessageDigest md = MessageDigest.getInstance(algo); + md.update(password.getBytes("UTF-8")); + md.update(challenge.getBytes("UTF-8")); + byte[] digest = md.digest(); + pwhash += toHex(digest); + } catch (NoSuchAlgorithmException | UnsupportedEncodingException e) { + throw new AssertionError("internal error: " + e.toString()); } // TODO: some day when we need this, we should store // this - if (chaltok[4].equals("BIG")) { - // byte-order of server is big-endian - } else if (chaltok[4].equals("LIT")) { - // byte-order of server is little-endian - } else { - throw new MCLParseException("Invalid byte-order: " + chaltok[5]); + switch (chaltok[4]) { + case "BIG": + // byte-order of server is big-endian + break; + case "LIT": + // byte-order of server is little-endian + break; + default: + throw new MCLParseException("Invalid byte-order: " + chaltok[5]); } // generate response @@ -567,9 +576,9 @@ public final class MapiSocket { private static String toHex(byte[] digest) { char[] result = new char[digest.length * 2]; int pos = 0; - for (int i = 0; i < digest.length; i++) { - result[pos++] = hexChar((digest[i] & 0xf0) >> 4); - result[pos++] = hexChar(digest[i] & 0x0f); + for (byte aDigest : digest) { + result[pos++] = hexChar((aDigest & 0xf0) >> 4); + result[pos++] = hexChar(aDigest & 0x0f); } return new String(result); } @@ -765,7 +774,7 @@ public final class MapiSocket { @Override public void write(byte[] b, int off, int len) throws IOException { - int t = 0; + int t; while (len > 0) { t = BLOCK - writePos; if (len > t) { @@ -971,8 +980,7 @@ public final class MapiSocket { if (size != 0) break; if (readBlock() == -1) { - if (size == 0) - size = -1; + size = -1; break; } t = available(); @@ -996,7 +1004,7 @@ public final class MapiSocket { @Override public long skip(long n) throws IOException { long skip = n; - int t = 0; + int t; while (skip > 0) { t = available(); if (skip > t) {
--- a/src/main/java/nl/cwi/monetdb/mcl/parser/TupleLineParser.java +++ b/src/main/java/nl/cwi/monetdb/mcl/parser/TupleLineParser.java @@ -34,7 +34,7 @@ public class TupleLineParser extends MCL * * @param source a String which should be parsed * @return 0, as there is no 'type' of TupleLine - * @throws ParseException if an error occurs during parsing + * @throws MCLParseException if an error occurs during parsing */ @Override public int parse(String source) throws MCLParseException {
--- a/src/main/java/nl/cwi/monetdb/merovingian/Control.java +++ b/src/main/java/nl/cwi/monetdb/merovingian/Control.java @@ -124,9 +124,7 @@ public class Control { ms.connect(host, port, "monetdb", passphrase); min = ms.getReader(); mout = ms.getWriter(); - } catch (MCLParseException e) { - throw new MerovingianException(e.getMessage()); - } catch (MCLException e) { + } catch (MCLParseException | MCLException e) { throw new MerovingianException(e.getMessage()); } catch (AssertionError e) { // mcl panics ms.close(); @@ -189,7 +187,7 @@ public class Control { if (!hasOutput) return null; - ArrayList<String> l = new ArrayList<String>(); + ArrayList<String> l = new ArrayList<>(); while ((response = in.readLine()) != null) { l.add(response); } @@ -202,7 +200,7 @@ public class Control { } mout.writeLine(database + " " + command + "\n"); - ArrayList<String> l = new ArrayList<String>(); + ArrayList<String> l = new ArrayList<>(); String tmpLine = min.readLine(); int linetype = min.getLineType(); if (linetype == BufferedMCLReader.ERROR) @@ -343,7 +341,7 @@ public class Control { /** * Test whether a specific database exists. * - * @param database + * @param database The database name * @return true, iff database already exists. * @throws MerovingianException * @throws IOException @@ -363,7 +361,7 @@ public class Control { public List<SabaothDB> getAllStatuses() throws MerovingianException, IOException { - List<SabaothDB> l = new ArrayList<SabaothDB>(); + List<SabaothDB> l = new ArrayList<>(); List<String> response = sendCommand("#all", "status", true); try { for (String responseLine : response) {
--- a/src/main/java/nl/cwi/monetdb/merovingian/SabaothDB.java +++ b/src/main/java/nl/cwi/monetdb/merovingian/SabaothDB.java @@ -137,7 +137,7 @@ public class SabaothDB { } else { this.uri = parts[pc++]; } - this.locked = parts[pc++].equals("1") ? true : false; + this.locked = parts[pc++].equals("1"); this.state = SABdbState.getInstance(Integer.parseInt(parts[pc++])); this.scenarios = parts[pc++].split("'"); if (protover == 1) /* skip connections */ @@ -171,7 +171,7 @@ public class SabaothDB { } else { this.lastStop = null; } - this.crashAvg1 = parts[pc++].equals("1") ? true : false; + this.crashAvg1 = parts[pc++].equals("1"); this.crashAvg10 = Double.parseDouble(parts[pc++]); this.crashAvg30 = Double.parseDouble(parts[pc++]); }
--- a/src/main/java/nl/cwi/monetdb/util/CmdLineOpts.java +++ b/src/main/java/nl/cwi/monetdb/util/CmdLineOpts.java @@ -281,7 +281,7 @@ public class CmdLineOpts { int cardinality; String shorta; String longa; - List<String> values = new ArrayList<String>(); + List<String> values = new ArrayList<>(); String name; String defaulta; String descriptiona;
--- a/src/main/java/nl/cwi/monetdb/util/Exporter.java +++ b/src/main/java/nl/cwi/monetdb/util/Exporter.java @@ -41,7 +41,7 @@ public abstract class Exporter { /** * returns the given string between two double quotes for usage as - * identifier such as column or table name in SQL queries. + * identifier such as columns or table name in SQL queries. * * @param in the string to quote * @return the quoted string
--- a/src/main/java/nl/cwi/monetdb/util/Extract.java +++ b/src/main/java/nl/cwi/monetdb/util/Extract.java @@ -44,9 +44,9 @@ public class Extract { throws FileNotFoundException, IOException { char[] cbuf = new char[DEFAULT_BUFSIZE]; - int ret = 0; + int ret; - InputStream is = new Extract().getClass().getResourceAsStream(fromFile); + InputStream is = Extract.class.getResourceAsStream(fromFile); if(is == null) { throw new FileNotFoundException("File " + fromFile +
--- a/src/main/java/nl/cwi/monetdb/util/SQLExporter.java +++ b/src/main/java/nl/cwi/monetdb/util/SQLExporter.java @@ -27,7 +27,7 @@ public class SQLExporter extends Exporte private Stack<String> lastSchema; public final static int TYPE_OUTPUT = 1; - public final static int VALUE_INSERT = 0; + public final static int VALUE_INSERT = 0; public final static int VALUE_COPY = 1; public final static int VALUE_TABLE = 2; @@ -38,7 +38,7 @@ public class SQLExporter extends Exporte /** * A helper method to generate SQL CREATE code for a given table. * This method performs all required lookups to find all relations and - * column information, as well as additional indices. + * columns information, as well as additional indices. * * @param dbmd a DatabaseMetaData object to query on (not null) * @param type the type of the object, e.g. VIEW, TABLE (not null) @@ -66,7 +66,7 @@ public class SQLExporter extends Exporte changeSchema(schema); // handle views directly - if (type.indexOf("VIEW") != -1) { + if (type.contains("VIEW")) { String[] types = new String[1]; types[0] = type; ResultSet tbl = dbmd.getTables(catalog, schema, name, types); @@ -103,7 +103,7 @@ public class SQLExporter extends Exporte for (i = 0; cols.next(); i++) { if (i > 0) out.println(","); - // print column name (with double quotes) + // print columns name (with double quotes) s = dq(cols.getString(colNmIndex)); out.print("\t" + s + repeat(' ', (colwidth - s.length() + 3))); @@ -116,25 +116,31 @@ public class SQLExporter extends Exporte s = cols.getString(colTypeNmIndex).toUpperCase(); // do some data type substitutions to match SQL standard - if (s.equals("INT")) { - s = "INTEGER"; - } else if (s.equals("SEC_INTERVAL")) { - s = "INTERVAL SECOND"; - } else if (s.equals("MONTH_INTERVAL")) { - s = "INTERVAL MONTH"; - } else if (s.equals("TIMETZ")) { - s = "TIME"; - // small hack to get desired behaviour: set digits when we have - // a time with time zone and at the same time masking the internal types - digits = 1; - } else if (s.equals("TIMESTAMPTZ")) { - s = "TIMESTAMP"; - // small hack to get desired behaviour: set digits when we have - // a timestamp with time zone and at the same time masking the internal types - digits = 1; + switch (s) { + case "INT": + s = "INTEGER"; + break; + case "SEC_INTERVAL": + s = "INTERVAL SECOND"; + break; + case "MONTH_INTERVAL": + s = "INTERVAL MONTH"; + break; + case "TIMETZ": + s = "TIME"; + // small hack to get desired behaviour: set digits when we have + // a time with time zone and at the same time masking the internal types + digits = 1; + break; + case "TIMESTAMPTZ": + s = "TIMESTAMP"; + // small hack to get desired behaviour: set digits when we have + // a timestamp with time zone and at the same time masking the internal types + digits = 1; + break; } - sb.append(s); // add the data type for this column + sb.append(s); // add the data type for this columns // do some SQL/MonetDB type length/precision and scale specifics switch (ctype) { @@ -172,22 +178,22 @@ public class SQLExporter extends Exporte sb.append(" DEFAULT ").append(defaultValue); } - // print column type, optional length and scale, optional Not NULL, optional default value + // print columns type, optional length and scale, optional Not NULL, optional default value out.print(sb.toString()); - sb.delete(0, sb.length()); // clear the stringbuffer for next column + sb.delete(0, sb.length()); // clear the stringbuffer for next columns } cols.close(); // add the primary key constraint definition // unfortunately some idiot defined that getPrimaryKeys() - // returns the primary key columns sorted by column name, not + // returns the primary key columns sorted by columns name, not // key sequence order. So we have to sort ourself :( cols = dbmd.getPrimaryKeys(catalog, schema, name); - // first make an 'index' of the KEY_SEQ column - SortedMap<Integer, Integer> seqIndex = new TreeMap<Integer, Integer>(); + // first make an 'index' of the KEY_SEQ columns + SortedMap<Integer, Integer> seqIndex = new TreeMap<>(); for (i = 1; cols.next(); i++) { - seqIndex.put(Integer.valueOf(cols.getInt("KEY_SEQ")), Integer.valueOf(i)); + seqIndex.put(cols.getInt("KEY_SEQ"), i); } if (seqIndex.size() > 0) { // terminate the previous line @@ -200,7 +206,7 @@ public class SQLExporter extends Exporte it.hasNext(); i++) { Map.Entry<Integer, Integer> e = it.next(); - cols.absolute(e.getValue().intValue()); + cols.absolute(e.getValue()); if (i > 0) out.print(", "); out.print(dq(cols.getString("COLUMN_NAME"))); @@ -241,9 +247,9 @@ public class SQLExporter extends Exporte out.print("\tCONSTRAINT " + dq(cols.getString("FK_NAME")) + " FOREIGN KEY ("); boolean next; - Set<String> fk = new LinkedHashSet<String>(); + Set<String> fk = new LinkedHashSet<>(); fk.add(cols.getString("FKCOLUMN_NAME").intern()); - Set<String> pk = new LinkedHashSet<String>(); + Set<String> pk = new LinkedHashSet<>(); pk.add(cols.getString("PKCOLUMN_NAME").intern()); while ((next = cols.next()) && @@ -363,7 +369,6 @@ public class SQLExporter extends Exporte * format. * * @param rs the ResultSet to convert into INSERT INTO statements - * @param absolute if true, dumps table name prepended with schema name * @throws SQLException if a database related error occurs */ private void resultSetToSQL(ResultSet rs) @@ -469,10 +474,7 @@ public class SQLExporter extends Exporte strbuf.append('|'); for (int j = 1; j < width.length; j++) { String colLabel = md.getColumnLabel(j); - strbuf.append(' '); - strbuf.append(colLabel); - strbuf.append(repeat(' ', width[j] - colLabel.length())); - strbuf.append(" |"); + strbuf.append(' ').append(colLabel).append(repeat(' ', width[j] - colLabel.length())).append(" |"); } // print the header text out.println(outsideLine); @@ -520,7 +522,7 @@ public class SQLExporter extends Exporte private void changeSchema(String schema) { if (lastSchema == null) { - lastSchema = new Stack<String>(); + lastSchema = new Stack<>(); lastSchema.push(null); }
--- a/src/main/java/nl/cwi/monetdb/util/SQLRestore.java +++ b/src/main/java/nl/cwi/monetdb/util/SQLRestore.java @@ -100,7 +100,7 @@ public class SQLRestore { /** * Restores a given SQL dump to the database. * - * @param source + * @param source File location of the SQL dump * @throws IOException */ public void restore(File source) throws IOException { @@ -120,16 +120,16 @@ public class SQLRestore { try { // FIXME: we assume here that the dump is in system's default encoding BufferedReader sourceData = new BufferedReader(new FileReader(source)); - try { + try { os.write('s'); // signal that a new statement (or series of) is coming while(!srr.inErrorState()) { char[] buf = new char[4096]; int result = sourceData.read(buf); - if (result < 0) - break; + if (result < 0) + break; os.write(buf, 0, result); } - + os.flush(); // mark the end of the statement (or series of) os.close(); } finally { @@ -147,9 +147,7 @@ public class SQLRestore { throw new IOException(srr.getErrorMessage()); } } - } catch (MCLException e) { - throw new IOException(e.getMessage()); - } catch (MCLParseException e) { + } catch (MCLException | MCLParseException e) { throw new IOException(e.getMessage()); } finally { ms.close();
--- a/src/main/java/nl/cwi/monetdb/util/XMLExporter.java +++ b/src/main/java/nl/cwi/monetdb/util/XMLExporter.java @@ -51,7 +51,7 @@ public class XMLExporter extends Exporte ResultSet cols = dbmd.getColumns(catalog, schema, name, null); String ident; - Set<String> types = new HashSet<String>(); + Set<String> types = new HashSet<>(); // walk through the ResultSet and create the types // for a bit of a clue on the types, see this url: // http://books.xmlschemata.org/relaxng/relax-CHP-19.html