-
Notifications
You must be signed in to change notification settings - Fork 556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No-op flags #2030
No-op flags #2030
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -118,14 +118,22 @@ public PreparedStatement prepareStatement(String sql) throws SQLException { | |
@Override | ||
public CallableStatement prepareCall(String sql) throws SQLException { | ||
checkOpen(); | ||
throw new SQLFeatureNotSupportedException("CallableStatement not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED); | ||
if (!config.isIgnoreUnsupportedRequests()) { | ||
throw new SQLFeatureNotSupportedException("CallableStatement not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
@Override | ||
public String nativeSQL(String sql) throws SQLException { | ||
checkOpen(); | ||
/// TODO: this is not implemented according to JDBC spec and may not be used. | ||
throw new SQLFeatureNotSupportedException("nativeSQL not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED); | ||
if (!config.isIgnoreUnsupportedRequests()) { | ||
throw new SQLFeatureNotSupportedException("nativeSQL not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED); | ||
} | ||
|
||
return null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. may be return the same sql? + javadoc that it is not implemented according to the spec if flag is true |
||
} | ||
|
||
@Override | ||
|
@@ -181,7 +189,7 @@ public DatabaseMetaData getMetaData() throws SQLException { | |
@Override | ||
public void setReadOnly(boolean readOnly) throws SQLException { | ||
checkOpen(); | ||
if (readOnly) { | ||
if (!config.isIgnoreUnsupportedRequests() && readOnly) { | ||
throw new SQLFeatureNotSupportedException("read-only=true unsupported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED); | ||
} | ||
} | ||
|
@@ -206,7 +214,7 @@ public String getCatalog() throws SQLException { | |
@Override | ||
public void setTransactionIsolation(int level) throws SQLException { | ||
checkOpen(); | ||
if (TRANSACTION_NONE != level) { | ||
if (!config.isIgnoreUnsupportedRequests() && TRANSACTION_NONE != level) { | ||
throw new SQLFeatureNotSupportedException("setTransactionIsolation not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED); | ||
} | ||
} | ||
|
@@ -243,19 +251,29 @@ public PreparedStatement prepareStatement(String sql, int resultSetType, int res | |
@Override | ||
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException { | ||
checkOpen(); | ||
throw new SQLFeatureNotSupportedException("CallableStatement not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED); | ||
if (!config.isIgnoreUnsupportedRequests()) { | ||
throw new SQLFeatureNotSupportedException("CallableStatement not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED); | ||
} | ||
|
||
return null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the same - this is whole functionality and it will be NPE anyway. so Exception should be thrown all the time |
||
} | ||
|
||
@Override | ||
public Map<String, Class<?>> getTypeMap() throws SQLException { | ||
checkOpen(); | ||
throw new SQLFeatureNotSupportedException("getTypeMap not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED); | ||
if (!config.isIgnoreUnsupportedRequests()) { | ||
throw new SQLFeatureNotSupportedException("getTypeMap not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED); | ||
} | ||
|
||
return null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This kind of missing functionality. I would return an empty map at least to not cause NPE. |
||
} | ||
|
||
@Override | ||
public void setTypeMap(Map<String, Class<?>> map) throws SQLException { | ||
checkOpen(); | ||
throw new SQLFeatureNotSupportedException("setTypeMap not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED); | ||
if (!config.isIgnoreUnsupportedRequests()) { | ||
throw new SQLFeatureNotSupportedException("setTypeMap not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED); | ||
} | ||
} | ||
|
||
@Override | ||
|
@@ -273,13 +291,21 @@ public int getHoldability() throws SQLException { | |
@Override | ||
public Savepoint setSavepoint() throws SQLException { | ||
checkOpen(); | ||
throw new SQLFeatureNotSupportedException("Savepoint not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED); | ||
if (!config.isIgnoreUnsupportedRequests()) { | ||
throw new SQLFeatureNotSupportedException("Savepoint not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
@Override | ||
public Savepoint setSavepoint(String name) throws SQLException { | ||
checkOpen(); | ||
throw new SQLFeatureNotSupportedException("Savepoint not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED); | ||
if (!config.isIgnoreUnsupportedRequests()) { | ||
throw new SQLFeatureNotSupportedException("Savepoint not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
@Override | ||
|
@@ -293,7 +319,9 @@ public void rollback(Savepoint savepoint) throws SQLException { | |
@Override | ||
public void releaseSavepoint(Savepoint savepoint) throws SQLException { | ||
checkOpen(); | ||
throw new SQLFeatureNotSupportedException("Savepoint not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED); | ||
if (!config.isIgnoreUnsupportedRequests()) { | ||
throw new SQLFeatureNotSupportedException("Savepoint not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED); | ||
} | ||
} | ||
|
||
@Override | ||
|
@@ -311,7 +339,11 @@ public PreparedStatement prepareStatement(String sql, int resultSetType, int res | |
@Override | ||
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { | ||
checkOpen(); | ||
throw new SQLFeatureNotSupportedException("CallableStatement not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED); | ||
if (!config.isIgnoreUnsupportedRequests()) { | ||
throw new SQLFeatureNotSupportedException("CallableStatement not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
@Override | ||
|
@@ -350,25 +382,41 @@ public PreparedStatement prepareStatement(String sql, String[] columnNames) thro | |
@Override | ||
public Clob createClob() throws SQLException { | ||
checkOpen(); | ||
throw new SQLFeatureNotSupportedException("Clob not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED); | ||
if (!config.isIgnoreUnsupportedRequests()) { | ||
throw new SQLFeatureNotSupportedException("Clob not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
@Override | ||
public Blob createBlob() throws SQLException { | ||
checkOpen(); | ||
throw new SQLFeatureNotSupportedException("Blob not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED); | ||
if (!config.isIgnoreUnsupportedRequests()) { | ||
throw new SQLFeatureNotSupportedException("Blob not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
@Override | ||
public NClob createNClob() throws SQLException { | ||
checkOpen(); | ||
throw new SQLFeatureNotSupportedException("NClob not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED); | ||
if (!config.isIgnoreUnsupportedRequests()) { | ||
throw new SQLFeatureNotSupportedException("NClob not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
@Override | ||
public SQLXML createSQLXML() throws SQLException { | ||
checkOpen(); | ||
throw new SQLFeatureNotSupportedException("SQLXML not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED); | ||
if (!config.isIgnoreUnsupportedRequests()) { | ||
throw new SQLFeatureNotSupportedException("SQLXML not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
@Override | ||
|
@@ -445,7 +493,11 @@ public Array createArrayOf(String typeName, Object[] elements) throws SQLExcepti | |
@Override | ||
public Struct createStruct(String typeName, Object[] attributes) throws SQLException { | ||
//TODO: Should this be supported? | ||
throw new SQLFeatureNotSupportedException("createStruct not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED); | ||
if (!config.isIgnoreUnsupportedRequests()) { | ||
throw new SQLFeatureNotSupportedException("createStruct not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
@Override | ||
|
@@ -462,19 +514,27 @@ public String getSchema() throws SQLException { | |
|
||
@Override | ||
public void abort(Executor executor) throws SQLException { | ||
throw new SQLFeatureNotSupportedException("abort not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED); | ||
if (!config.isIgnoreUnsupportedRequests()) { | ||
throw new SQLFeatureNotSupportedException("abort not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED); | ||
} | ||
} | ||
|
||
@Override | ||
public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException { | ||
//TODO: Should this be supported? | ||
throw new SQLFeatureNotSupportedException("setNetworkTimeout not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED); | ||
if (!config.isIgnoreUnsupportedRequests()) { | ||
throw new SQLFeatureNotSupportedException("setNetworkTimeout not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED); | ||
} | ||
} | ||
|
||
@Override | ||
public int getNetworkTimeout() throws SQLException { | ||
//TODO: Should this be supported? | ||
throw new SQLFeatureNotSupportedException("getNetworkTimeout not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED); | ||
if (!config.isIgnoreUnsupportedRequests()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seems something missing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean it may be a useful timeout - we should take it from client. |
||
throw new SQLFeatureNotSupportedException("getNetworkTimeout not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED); | ||
} | ||
|
||
return -1; | ||
} | ||
|
||
@Override | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would think this is totally valid exception because if this is called then NPE will be thrown anyway.
In most cases we can ignore parameters, but not a whole functionality.