diff src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java @ 262:2d62ca1f758b

Moved utility method newSQLFeatureNotSupportedException(String name) from MonetPreparedStatement.java and MonetResultSet.java to class MonetWrapper such that it can be called directly from all classes which extend MonetWrapper. Call MonetWrapper.newSQLFeatureNotSupportedException() from more classes and places. Update java documentation: - add "@throws SQLFeatureNotSupportedException" to methods which can throw it - remove "@throws SQLFeatureNotSupportedException" from methods which do not throw it
author Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
date Thu, 03 Jan 2019 18:33:25 +0100 (2019-01-03)
parents d4baf8a4b43a
children eefa7f625673
line wrap: on
line diff
--- a/src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java
+++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java
@@ -32,7 +32,6 @@ import java.sql.RowId;
 import java.sql.SQLData;
 import java.sql.SQLDataException;
 import java.sql.SQLException;
-import java.sql.SQLFeatureNotSupportedException;
 import java.sql.SQLInput;
 import java.sql.SQLWarning;
 import java.sql.SQLXML;
@@ -519,8 +518,6 @@ public class MonetResultSet
 	 *         if the value is SQL NULL, the value returned is null in
 	 *         the Java programming language.
 	 * @throws SQLException if a database access error occurs
-	 * @throws SQLFeatureNotSupportedException the JDBC driver does
-	 *         not support this method
 	 */
 	@Override
 	public Reader getNCharacterStream(int columnIndex) throws SQLException {
@@ -538,8 +535,6 @@ public class MonetResultSet
 	 *         if the value is SQL NULL, the value returned is null in
 	 *         the Java programming language.
 	 * @throws SQLException if a database access error occurs
-	 * @throws SQLFeatureNotSupportedException the JDBC driver does
-	 *         not support this method
 	 */
 	@Override
 	public Reader getNCharacterStream(String columnLabel) throws SQLException {
@@ -2268,6 +2263,8 @@ public class MonetResultSet
 	 *         null or another error occurs. The getCause() method of
 	 *         the exception may provide a more detailed exception, for
 	 *         example, if a conversion error occurs
+	 * @throws SQLFeatureNotSupportedException the JDBC driver does
+	 *         not support this method
 	 */
 	@Override
 	public <T> T getObject(int columnIndex, Class<T> type) throws SQLException {
@@ -2275,7 +2272,7 @@ public class MonetResultSet
 		if (type == null)
 			throw new SQLException("type is null", "M1M05");
 
-		throw new SQLFeatureNotSupportedException("cannot return a Java generic type based on static types from getXXX methods", "0AM34");
+		throw newSQLFeatureNotSupportedException("getObject(column, Class<T> type)");
 	}
 
 	/**
@@ -2295,11 +2292,11 @@ public class MonetResultSet
 	 *         null or another error occurs. The getCause() method of
 	 *         the exception may provide a more detailed exception, for
 	 *         example, if a conversion error occurs
+	 * @throws SQLFeatureNotSupportedException the JDBC driver does
+	 *         not support this method
 	 */
 	@Override
-	public <T> T getObject(String columnLabel, Class<T> type)
-		throws SQLException
-	{
+	public <T> T getObject(String columnLabel, Class<T> type) throws SQLException {
 		return getObject(findColumn(columnLabel), type);
 	}
 
@@ -2552,8 +2549,6 @@ public class MonetResultSet
 	 * @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 null
 	 * @throws SQLException if there is no such column
-	 * @throws SQLFeatureNotSupportedException the JDBC driver does
-	 *         not support this method
 	 */
 	@Override
 	public String getNString(int columnIndex) throws SQLException {
@@ -2569,8 +2564,6 @@ public class MonetResultSet
 	 * @param columnLabel the SQL name of the column
 	 * @return the column value; if the value is SQL NULL, the value returned is null
 	 * @throws SQLException if the ResultSet object does not contain columnLabel
-	 * @throws SQLFeatureNotSupportedException the JDBC driver does
-	 *         not support this method
 	 */
 	@Override
 	public String getNString(String columnLabel) throws SQLException {
@@ -3309,7 +3302,6 @@ public class MonetResultSet
 	 *
 	 * Throws:
 	 *     SQLException - if a database access error occurs or this method is called on a closed result set
-	 *     SQLFeatureNotSupportedException - if the JDBC driver does not support this method
 	 * Since: 1.2
 	 * See Also: DatabaseMetaData.deletesAreDetected(int)
 	 */
@@ -3329,7 +3321,6 @@ public class MonetResultSet
 	 *
 	 * Throws:
 	 *     SQLException - if a database access error occurs or this method is called on a closed result set
-	 *     SQLFeatureNotSupportedException - if the JDBC driver does not support this method
 	 * Since: 1.2
 	 * See Also: DatabaseMetaData.insertsAreDetected(int)
 	 */
@@ -3349,7 +3340,6 @@ public class MonetResultSet
 	 *
 	 * Throws:
 	 *     SQLException - if a database access error occurs or this method is called on a closed result set
-	 *     SQLFeatureNotSupportedException - if the JDBC driver does not support this method
 	 * Since: 1.2
 	 * See Also: DatabaseMetaData.updatesAreDetected(int)
 	 */
@@ -3359,8 +3349,10 @@ public class MonetResultSet
 		return false;
 	}
 
-	/* the next methods are all related to updateable result sets, which we
-	   currently do not support */
+
+	/* Next methods are all related to updateable result sets, which we do not support.
+	 * @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method
+	 */
 	@Override
 	public void cancelRowUpdates() throws SQLException {
 		throw newSQLFeatureNotSupportedException("cancelRowUpdates");
@@ -3403,7 +3395,7 @@ public class MonetResultSet
 	}
 
 	@Override
-	public void updateAsciiStream(int columnIndex, InputStream xh) throws SQLException {
+	public void updateAsciiStream(int columnIndex, InputStream x) throws SQLException {
 		throw newSQLFeatureNotSupportedException("updateAsciiStream");
 	}
 
@@ -3786,12 +3778,12 @@ public class MonetResultSet
 	}
 
 	@Override
-	public void updateSQLXML(String columnLabel, SQLXML x) throws SQLException {
+	public void updateSQLXML(int columnIndex, SQLXML x) throws SQLException {
 		throw newSQLFeatureNotSupportedException("updateSQLXML");
 	}
 
 	@Override
-	public void updateSQLXML(int columnIndex, SQLXML x) throws SQLException {
+	public void updateSQLXML(String columnLabel, SQLXML x) throws SQLException {
 		throw newSQLFeatureNotSupportedException("updateSQLXML");
 	}
 
@@ -3880,17 +3872,5 @@ public class MonetResultSet
 	private static final SQLDataException newSQLNumberFormatException(NumberFormatException error) {
 		return new SQLDataException("Could not convert value to a number. " + error.getMessage(), "22003");
 	}
-
-	/**
-	 * Small helper method that formats the "Method ... not implemented" message
-	 * and creates a new SQLFeatureNotSupportedException object
-	 * whose SQLState is set to "0A000": feature not supported.
-	 *
-	 * @param name the method name
-	 * @return a new created SQLFeatureNotSupportedException object with SQLState 0A000
-	 */
-	private static final SQLFeatureNotSupportedException newSQLFeatureNotSupportedException(String name) {
-		return new SQLFeatureNotSupportedException("Method " + name + " not implemented", "0A000");
-	}
 }