提交 b9da747d 编写于 作者: Z zyyang

change

上级 3c83219f
......@@ -19,6 +19,7 @@ import java.util.Map;
public abstract class TSDBConstants {
public static final String STATEMENT_CLOSED = "Statement already closed.";
public static final String DEFAULT_PORT = "6200";
public static final String UNSUPPORT_METHOD_EXCEPTIONZ_MSG = "this operation is NOT supported currently!";
public static final String INVALID_VARIABLES = "invalid variables";
......
......@@ -136,10 +136,15 @@ public class TSDBStatement implements Statement {
}
public void setMaxFieldSize(int max) throws SQLException {
if (isClosed())
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
public int getMaxRows() throws SQLException {
if (isClosed())
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
// always set maxRows to zero, meaning unlimitted rows in a resultSet
return 0;
}
......
......@@ -14,7 +14,6 @@ import java.util.stream.Collectors;
public class RestfulStatement implements Statement {
private static final String STATEMENT_CLOSED = "Statement already closed.";
private boolean closed;
private String database;
private final RestfulConnection conn;
......@@ -131,14 +130,14 @@ public class RestfulStatement implements Statement {
@Override
public int getMaxFieldSize() throws SQLException {
if (isClosed())
throw new SQLException(STATEMENT_CLOSED);
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
return TSDBConstants.maxFieldSize;
}
@Override
public void setMaxFieldSize(int max) throws SQLException {
if (isClosed())
throw new SQLException(STATEMENT_CLOSED);
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
if (max < 0)
throw new SQLException(TSDBConstants.INVALID_VARIABLES);
// nothing to do
......@@ -147,14 +146,14 @@ public class RestfulStatement implements Statement {
@Override
public int getMaxRows() throws SQLException {
if (isClosed())
throw new SQLException(STATEMENT_CLOSED);
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
return 0;
}
@Override
public void setMaxRows(int max) throws SQLException {
if (isClosed())
throw new SQLException(STATEMENT_CLOSED);
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
if (max < 0)
throw new SQLException(TSDBConstants.INVALID_VARIABLES);
// nothing to do
......@@ -163,20 +162,20 @@ public class RestfulStatement implements Statement {
@Override
public void setEscapeProcessing(boolean enable) throws SQLException {
if (isClosed())
throw new SQLException(RestfulStatement.STATEMENT_CLOSED);
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
}
@Override
public int getQueryTimeout() throws SQLException {
if (isClosed())
throw new SQLException(STATEMENT_CLOSED);
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
return 0;
}
@Override
public void setQueryTimeout(int seconds) throws SQLException {
if (isClosed())
throw new SQLException(STATEMENT_CLOSED);
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
if (seconds < 0)
throw new SQLException(TSDBConstants.INVALID_VARIABLES);
}
......@@ -189,7 +188,7 @@ public class RestfulStatement implements Statement {
@Override
public SQLWarning getWarnings() throws SQLException {
if (isClosed())
throw new SQLException(STATEMENT_CLOSED);
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
return null;
}
......@@ -197,13 +196,13 @@ public class RestfulStatement implements Statement {
public void clearWarnings() throws SQLException {
// nothing to do
if (isClosed())
throw new SQLException(STATEMENT_CLOSED);
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
}
@Override
public void setCursorName(String name) throws SQLException {
if (isClosed())
throw new SQLException(RestfulStatement.STATEMENT_CLOSED);
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
}
......@@ -243,7 +242,7 @@ public class RestfulStatement implements Statement {
@Override
public ResultSet getResultSet() throws SQLException {
if (isClosed())
throw new SQLException(STATEMENT_CLOSED);
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
return resultSet;
}
......@@ -275,7 +274,7 @@ public class RestfulStatement implements Statement {
@Override
public void setFetchSize(int rows) throws SQLException {
if (isClosed())
throw new SQLException(STATEMENT_CLOSED);
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
if (rows < 0)
throw new SQLException(TSDBConstants.INVALID_VARIABLES);
//nothing to do
......@@ -284,28 +283,28 @@ public class RestfulStatement implements Statement {
@Override
public int getFetchSize() throws SQLException {
if (isClosed())
throw new SQLException(STATEMENT_CLOSED);
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
return 0;
}
@Override
public int getResultSetConcurrency() throws SQLException {
if (isClosed())
throw new SQLException(STATEMENT_CLOSED);
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
return this.resultSet.getConcurrency();
}
@Override
public int getResultSetType() throws SQLException {
if (isClosed())
throw new SQLException(STATEMENT_CLOSED);
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
return this.resultSet.getType();
}
@Override
public void addBatch(String sql) throws SQLException {
if (isClosed())
throw new SQLException(STATEMENT_CLOSED);
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
//TODO:
}
......@@ -323,14 +322,14 @@ public class RestfulStatement implements Statement {
@Override
public Connection getConnection() throws SQLException {
if (isClosed())
throw new SQLException(STATEMENT_CLOSED);
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
return this.conn;
}
@Override
public boolean getMoreResults(int current) throws SQLException {
if (isClosed())
throw new SQLException(STATEMENT_CLOSED);
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
if (resultSet == null)
return false;
......@@ -388,7 +387,7 @@ public class RestfulStatement implements Statement {
@Override
public int getResultSetHoldability() throws SQLException {
if (isClosed())
throw new SQLException(STATEMENT_CLOSED);
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
return this.resultSet.getHoldability();
}
......@@ -400,28 +399,28 @@ public class RestfulStatement implements Statement {
@Override
public void setPoolable(boolean poolable) throws SQLException {
if (isClosed())
throw new SQLException(STATEMENT_CLOSED);
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
//nothing to do
}
@Override
public boolean isPoolable() throws SQLException {
if (isClosed())
throw new SQLException(STATEMENT_CLOSED);
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
return false;
}
@Override
public void closeOnCompletion() throws SQLException {
if (isClosed())
throw new SQLException(STATEMENT_CLOSED);
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
this.closeOnCompletion = true;
}
@Override
public boolean isCloseOnCompletion() throws SQLException {
if (isClosed())
throw new SQLException(STATEMENT_CLOSED);
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
return this.closeOnCompletion;
}
......
......@@ -66,7 +66,7 @@ public class StatementTest {
assertEquals(false, isClosed);
}
@Test(expected = SQLFeatureNotSupportedException.class)
@Test(expected = SQLException.class)
public void testUnsupport() {
try {
Assert.assertNotNull(statement.unwrap(TSDBStatement.class));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册