提交 1538a750 authored 作者: noelgrandin@gmail.com's avatar noelgrandin@gmail.com

remove unnecessary throws clauses from methods

上级 88109360
...@@ -237,7 +237,7 @@ public class JdbcArray extends TraceObject implements Array { ...@@ -237,7 +237,7 @@ public class JdbcArray extends TraceObject implements Array {
return rs; return rs;
} }
private void checkClosed() throws SQLException { private void checkClosed() {
conn.checkClosed(); conn.checkClosed();
if (value == null) { if (value == null) {
throw DbException.get(ErrorCode.OBJECT_CLOSED); throw DbException.get(ErrorCode.OBJECT_CLOSED);
......
...@@ -313,7 +313,7 @@ public class JdbcBlob extends TraceObject implements Blob { ...@@ -313,7 +313,7 @@ public class JdbcBlob extends TraceObject implements Blob {
throw unsupported("LOB update"); throw unsupported("LOB update");
} }
private void checkClosed() throws SQLException { private void checkClosed() {
conn.checkClosed(); conn.checkClosed();
if (value == null) { if (value == null) {
throw DbException.get(ErrorCode.OBJECT_CLOSED); throw DbException.get(ErrorCode.OBJECT_CLOSED);
......
...@@ -1510,7 +1510,7 @@ public class JdbcCallableStatement extends JdbcPreparedStatement implements Call ...@@ -1510,7 +1510,7 @@ public class JdbcCallableStatement extends JdbcPreparedStatement implements Call
return meta; return meta;
} }
private void checkIndexBounds(int parameterIndex) throws SQLException { private void checkIndexBounds(int parameterIndex) {
checkClosed(); checkClosed();
if (parameterIndex < 1 || parameterIndex > maxOutParameters) { if (parameterIndex < 1 || parameterIndex > maxOutParameters) {
throw DbException.getInvalidValueException("parameterIndex", parameterIndex); throw DbException.getInvalidValueException("parameterIndex", parameterIndex);
......
...@@ -260,7 +260,7 @@ public class JdbcClob extends TraceObject implements Clob ...@@ -260,7 +260,7 @@ public class JdbcClob extends TraceObject implements Clob
} }
//## Java 1.6 end ## //## Java 1.6 end ##
private void checkClosed() throws SQLException { private void checkClosed() {
conn.checkClosed(); conn.checkClosed();
if (value == null) { if (value == null) {
throw DbException.get(ErrorCode.OBJECT_CLOSED); throw DbException.get(ErrorCode.OBJECT_CLOSED);
......
...@@ -1332,9 +1332,9 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -1332,9 +1332,9 @@ public class JdbcConnection extends TraceObject implements Connection {
* Check if this connection is closed. * Check if this connection is closed.
* The next operation is a read request. * The next operation is a read request.
* *
* @throws SQLException if the connection or session is closed * @throws DbException if the connection or session is closed
*/ */
protected void checkClosed() throws SQLException { protected void checkClosed() {
checkClosed(false); checkClosed(false);
} }
...@@ -1342,9 +1342,9 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -1342,9 +1342,9 @@ public class JdbcConnection extends TraceObject implements Connection {
* Check if this connection is closed. * Check if this connection is closed.
* The next operation may be a write request. * The next operation may be a write request.
* *
* @throws SQLException if the connection or session is closed * @throws DbException if the connection or session is closed
*/ */
private void checkClosedForWrite() throws SQLException { private void checkClosedForWrite() {
checkClosed(true); checkClosed(true);
} }
...@@ -1353,9 +1353,9 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -1353,9 +1353,9 @@ public class JdbcConnection extends TraceObject implements Connection {
* Check if this connection is closed. * Check if this connection is closed.
* *
* @param write if the next operation is possibly writing * @param write if the next operation is possibly writing
* @throws SQLException if the connection or session is closed * @throws DbException if the connection or session is closed
*/ */
protected void checkClosed(boolean write) throws SQLException { protected void checkClosed(boolean write) {
if (session == null) { if (session == null) {
throw DbException.get(ErrorCode.OBJECT_CLOSED); throw DbException.get(ErrorCode.OBJECT_CLOSED);
} }
...@@ -1380,12 +1380,12 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -1380,12 +1380,12 @@ public class JdbcConnection extends TraceObject implements Connection {
} }
} }
String getURL() throws SQLException { String getURL() {
checkClosed(); checkClosed();
return url; return url;
} }
String getUser() throws SQLException { String getUser() {
checkClosed(); checkClosed();
return user; return user;
} }
......
...@@ -2737,7 +2737,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat ...@@ -2737,7 +2737,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
// ============================================================= // =============================================================
private void checkClosed() throws SQLException { private void checkClosed() {
conn.checkClosed(); conn.checkClosed();
} }
......
...@@ -196,7 +196,7 @@ public class JdbcParameterMetaData extends TraceObject implements ParameterMetaD ...@@ -196,7 +196,7 @@ public class JdbcParameterMetaData extends TraceObject implements ParameterMetaD
} }
} }
private ParameterInterface getParameter(int param) throws SQLException { private ParameterInterface getParameter(int param) {
checkClosed(); checkClosed();
if (param < 1 || param > paramCount) { if (param < 1 || param > paramCount) {
throw DbException.getInvalidValueException("param", param); throw DbException.getInvalidValueException("param", param);
...@@ -204,7 +204,7 @@ public class JdbcParameterMetaData extends TraceObject implements ParameterMetaD ...@@ -204,7 +204,7 @@ public class JdbcParameterMetaData extends TraceObject implements ParameterMetaD
return parameters.get(param - 1); return parameters.get(param - 1);
} }
private void checkClosed() throws SQLException { private void checkClosed() {
prep.checkClosed(); prep.checkClosed();
} }
......
...@@ -1262,7 +1262,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat ...@@ -1262,7 +1262,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
// ============================================================= // =============================================================
private void setParameter(int parameterIndex, Value value) throws SQLException { private void setParameter(int parameterIndex, Value value) {
checkClosed(); checkClosed();
parameterIndex--; parameterIndex--;
ArrayList<? extends ParameterInterface> parameters = command.getParameters(); ArrayList<? extends ParameterInterface> parameters = command.getParameters();
...@@ -1505,7 +1505,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat ...@@ -1505,7 +1505,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
return getTraceObjectName() + ": " + command; return getTraceObjectName() + ": " + command;
} }
protected boolean checkClosed(boolean write) throws SQLException { protected boolean checkClosed(boolean write) {
if (super.checkClosed(write)) { if (super.checkClosed(write)) {
// if the session was re-connected, re-prepare the statement // if the session was re-connected, re-prepare the statement
ArrayList<? extends ParameterInterface> oldParams = command.getParameters(); ArrayList<? extends ParameterInterface> oldParams = command.getParameters();
......
...@@ -2852,7 +2852,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet { ...@@ -2852,7 +2852,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
return row; return row;
} }
private int getColumnIndex(String columnLabel) throws SQLException { private int getColumnIndex(String columnLabel) {
checkClosed(); checkClosed();
if (columnLabel == null) { if (columnLabel == null) {
throw DbException.getInvalidValueException("columnLabel", null); throw DbException.getInvalidValueException("columnLabel", null);
...@@ -2912,7 +2912,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet { ...@@ -2912,7 +2912,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
throw DbException.get(ErrorCode.COLUMN_NOT_FOUND_1, columnLabel); throw DbException.get(ErrorCode.COLUMN_NOT_FOUND_1, columnLabel);
} }
private void checkColumnIndex(int columnIndex) throws SQLException { private void checkColumnIndex(int columnIndex) {
checkClosed(); checkClosed();
if (columnIndex < 1 || columnIndex > columnCount) { if (columnIndex < 1 || columnIndex > columnCount) {
throw DbException.getInvalidValueException("columnIndex", columnIndex); throw DbException.getInvalidValueException("columnIndex", columnIndex);
...@@ -2922,9 +2922,9 @@ public class JdbcResultSet extends TraceObject implements ResultSet { ...@@ -2922,9 +2922,9 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
/** /**
* Check if this result set is closed. * Check if this result set is closed.
* *
* @throws SQLException if it is closed * @throws DbException if it is closed
*/ */
void checkClosed() throws SQLException { void checkClosed() {
if (result == null) { if (result == null) {
throw DbException.get(ErrorCode.OBJECT_CLOSED); throw DbException.get(ErrorCode.OBJECT_CLOSED);
} }
...@@ -2942,7 +2942,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet { ...@@ -2942,7 +2942,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
} }
} }
private Value get(int columnIndex) throws SQLException { private Value get(int columnIndex) {
checkColumnIndex(columnIndex); checkColumnIndex(columnIndex);
checkOnValidRow(); checkOnValidRow();
Value[] list; Value[] list;
...@@ -2959,17 +2959,17 @@ public class JdbcResultSet extends TraceObject implements ResultSet { ...@@ -2959,17 +2959,17 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
return value; return value;
} }
private Value get(String columnLabel) throws SQLException { private Value get(String columnLabel) {
int columnIndex = getColumnIndex(columnLabel); int columnIndex = getColumnIndex(columnLabel);
return get(columnIndex); return get(columnIndex);
} }
private void update(String columnLabel, Value v) throws SQLException { private void update(String columnLabel, Value v) {
int columnIndex = getColumnIndex(columnLabel); int columnIndex = getColumnIndex(columnLabel);
update(columnIndex, v); update(columnIndex, v);
} }
private void update(int columnIndex, Value v) throws SQLException { private void update(int columnIndex, Value v) {
checkUpdatable(); checkUpdatable();
checkColumnIndex(columnIndex); checkColumnIndex(columnIndex);
if (insertRow != null) { if (insertRow != null) {
...@@ -3473,12 +3473,12 @@ public class JdbcResultSet extends TraceObject implements ResultSet { ...@@ -3473,12 +3473,12 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
} }
} }
private Value convertToUnknownValue(Object x) throws SQLException { private Value convertToUnknownValue(Object x) {
checkClosed(); checkClosed();
return DataType.convertToValue(conn.getSession(), x, Value.UNKNOWN); return DataType.convertToValue(conn.getSession(), x, Value.UNKNOWN);
} }
private void checkUpdatable() throws SQLException { private void checkUpdatable() {
checkClosed(); checkClosed();
if (!updatable) { if (!updatable) {
throw DbException.get(ErrorCode.RESULT_SET_READONLY); throw DbException.get(ErrorCode.RESULT_SET_READONLY);
......
...@@ -413,7 +413,7 @@ public class JdbcResultSetMetaData extends TraceObject implements ResultSetMetaD ...@@ -413,7 +413,7 @@ public class JdbcResultSetMetaData extends TraceObject implements ResultSetMetaD
} }
} }
private void checkClosed() throws SQLException { private void checkClosed() {
if (rs != null) { if (rs != null) {
rs.checkClosed(); rs.checkClosed();
} }
...@@ -422,7 +422,7 @@ public class JdbcResultSetMetaData extends TraceObject implements ResultSetMetaD ...@@ -422,7 +422,7 @@ public class JdbcResultSetMetaData extends TraceObject implements ResultSetMetaD
} }
} }
private void checkColumnIndex(int columnIndex) throws SQLException { private void checkColumnIndex(int columnIndex) {
checkClosed(); checkClosed();
if (columnIndex < 1 || columnIndex > columnCount) { if (columnIndex < 1 || columnIndex > columnCount) {
throw DbException.getInvalidValueException("columnIndex", columnIndex); throw DbException.getInvalidValueException("columnIndex", columnIndex);
......
...@@ -892,9 +892,9 @@ public class JdbcStatement extends TraceObject implements Statement { ...@@ -892,9 +892,9 @@ public class JdbcStatement extends TraceObject implements Statement {
* The next operation is a read request. * The next operation is a read request.
* *
* @return true if the session was re-connected * @return true if the session was re-connected
* @throws SQLException if the connection or session is closed * @throws DbException if the connection or session is closed
*/ */
boolean checkClosed() throws SQLException { boolean checkClosed() {
return checkClosed(false); return checkClosed(false);
} }
...@@ -903,9 +903,9 @@ public class JdbcStatement extends TraceObject implements Statement { ...@@ -903,9 +903,9 @@ public class JdbcStatement extends TraceObject implements Statement {
* The next operation may be a write request. * The next operation may be a write request.
* *
* @return true if the session was re-connected * @return true if the session was re-connected
* @throws SQLException if the connection or session is closed * @throws DbException if the connection or session is closed
*/ */
boolean checkClosedForWrite() throws SQLException { boolean checkClosedForWrite() {
return checkClosed(true); return checkClosed(true);
} }
...@@ -915,9 +915,9 @@ public class JdbcStatement extends TraceObject implements Statement { ...@@ -915,9 +915,9 @@ public class JdbcStatement extends TraceObject implements Statement {
* *
* @param write if the next operation is possibly writing * @param write if the next operation is possibly writing
* @return true if a reconnect was required * @return true if a reconnect was required
* @throws SQLException if it is closed * @throws DbException if it is closed
*/ */
protected boolean checkClosed(boolean write) throws SQLException { protected boolean checkClosed(boolean write) {
if (conn == null) { if (conn == null) {
throw DbException.get(ErrorCode.OBJECT_CLOSED); throw DbException.get(ErrorCode.OBJECT_CLOSED);
} }
......
...@@ -452,7 +452,7 @@ public class JdbcXAConnection extends TraceObject implements XAConnection, XARes ...@@ -452,7 +452,7 @@ public class JdbcXAConnection extends TraceObject implements XAConnection, XARes
return isClosed || super.isClosed(); return isClosed || super.isClosed();
} }
protected synchronized void checkClosed(boolean write) throws SQLException { protected synchronized void checkClosed(boolean write) {
if (isClosed) { if (isClosed) {
throw DbException.get(ErrorCode.OBJECT_CLOSED); throw DbException.get(ErrorCode.OBJECT_CLOSED);
} }
......
...@@ -469,7 +469,7 @@ public class TcpServer implements Service { ...@@ -469,7 +469,7 @@ public class TcpServer implements Service {
* @param sessionId the session id * @param sessionId the session id
* @param statementId the statement id * @param statementId the statement id
*/ */
void cancelStatement(String sessionId, int statementId) throws SQLException { void cancelStatement(String sessionId, int statementId) {
for (TcpServerThread c : New.arrayList(running)) { for (TcpServerThread c : New.arrayList(running)) {
if (c != null) { if (c != null) {
c.cancelStatement(sessionId, statementId); c.cancelStatement(sessionId, statementId);
...@@ -484,9 +484,9 @@ public class TcpServer implements Service { ...@@ -484,9 +484,9 @@ public class TcpServer implements Service {
* *
* @param db the key to test (or database name if no key is used) * @param db the key to test (or database name if no key is used)
* @return the database name * @return the database name
* @throws SQLException if a key is set but doesn't match * @throws DbException if a key is set but doesn't match
*/ */
public String checkKeyAndGetDatabaseName(String db) throws SQLException { public String checkKeyAndGetDatabaseName(String db) {
if (key == null) { if (key == null) {
return db; return db;
} }
......
...@@ -215,7 +215,7 @@ public class TcpServerThread implements Runnable { ...@@ -215,7 +215,7 @@ public class TcpServerThread implements Runnable {
} }
} }
private void process() throws IOException, SQLException { private void process() throws IOException {
int operation = transfer.readInt(); int operation = transfer.readInt();
switch (operation) { switch (operation) {
case SessionRemote.SESSION_PREPARE_READ_PARAMS: case SessionRemote.SESSION_PREPARE_READ_PARAMS:
...@@ -402,7 +402,7 @@ public class TcpServerThread implements Runnable { ...@@ -402,7 +402,7 @@ public class TcpServerThread implements Runnable {
* @param targetSessionId the session id * @param targetSessionId the session id
* @param statementId the statement to cancel * @param statementId the statement to cancel
*/ */
void cancelStatement(String targetSessionId, int statementId) throws SQLException { void cancelStatement(String targetSessionId, int statementId) {
if (StringUtils.equals(targetSessionId, this.sessionId)) { if (StringUtils.equals(targetSessionId, this.sessionId)) {
Command cmd = (Command) cache.getObject(statementId, false); Command cmd = (Command) cache.getObject(statementId, false);
cmd.cancel(); cmd.cancel();
......
...@@ -70,9 +70,8 @@ public class DeleteDbFiles extends Tool { ...@@ -70,9 +70,8 @@ public class DeleteDbFiles extends Tool {
* @param dir the directory * @param dir the directory
* @param db the database name (null for all databases) * @param db the database name (null for all databases)
* @param quiet don't print progress information * @param quiet don't print progress information
* @throws SQLException
*/ */
public static void execute(String dir, String db, boolean quiet) throws SQLException { public static void execute(String dir, String db, boolean quiet) {
new DeleteDbFiles().process(dir, db, quiet); new DeleteDbFiles().process(dir, db, quiet);
} }
...@@ -82,9 +81,8 @@ public class DeleteDbFiles extends Tool { ...@@ -82,9 +81,8 @@ public class DeleteDbFiles extends Tool {
* @param dir the directory * @param dir the directory
* @param db the database name (null for all databases) * @param db the database name (null for all databases)
* @param quiet don't print progress information * @param quiet don't print progress information
* @throws SQLException
*/ */
private void process(String dir, String db, boolean quiet) throws SQLException { private void process(String dir, String db, boolean quiet) {
ArrayList<String> files = FileLister.getDatabaseFiles(dir, db, true); ArrayList<String> files = FileLister.getDatabaseFiles(dir, db, true);
if (files.size() == 0 && !quiet) { if (files.size() == 0 && !quiet) {
printNoDatabaseFilesFound(dir, db); printNoDatabaseFilesFound(dir, db);
......
...@@ -132,9 +132,9 @@ public class Restore extends Tool { ...@@ -132,9 +132,9 @@ public class Restore extends Tool {
* @param directory the directory name * @param directory the directory name
* @param db the database name (null for all databases) * @param db the database name (null for all databases)
* @param quiet don't print progress information * @param quiet don't print progress information
* @throws SQLException * @throws DbException if there is an IOException
*/ */
public static void execute(String zipFileName, String directory, String db, boolean quiet) throws SQLException { public static void execute(String zipFileName, String directory, String db, boolean quiet) {
InputStream in = null; InputStream in = null;
try { try {
if (!IOUtils.exists(zipFileName)) { if (!IOUtils.exists(zipFileName)) {
......
...@@ -79,10 +79,10 @@ public class SmallMap { ...@@ -79,10 +79,10 @@ public class SmallMap {
* @param id the id of the object * @param id the id of the object
* @param ifAvailable only return it if available, otherwise return null * @param ifAvailable only return it if available, otherwise return null
* @return the object or null * @return the object or null
* @throws SQLException if isAvailable is false and the object has not been * @throws DbException if isAvailable is false and the object has not been
* found * found
*/ */
public Object getObject(int id, boolean ifAvailable) throws SQLException { public Object getObject(int id, boolean ifAvailable) {
if (id == cacheId) { if (id == cacheId) {
return cache; return cache;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论