change
This commit is contained in:
parent
3c83219fd9
commit
b9da747d2d
|
@ -19,6 +19,7 @@ import java.util.Map;
|
||||||
|
|
||||||
public abstract class TSDBConstants {
|
public abstract class TSDBConstants {
|
||||||
|
|
||||||
|
public static final String STATEMENT_CLOSED = "Statement already closed.";
|
||||||
public static final String DEFAULT_PORT = "6200";
|
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 UNSUPPORT_METHOD_EXCEPTIONZ_MSG = "this operation is NOT supported currently!";
|
||||||
public static final String INVALID_VARIABLES = "invalid variables";
|
public static final String INVALID_VARIABLES = "invalid variables";
|
||||||
|
|
|
@ -136,10 +136,15 @@ public class TSDBStatement implements Statement {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMaxFieldSize(int max) throws SQLException {
|
public void setMaxFieldSize(int max) throws SQLException {
|
||||||
|
if (isClosed())
|
||||||
|
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
||||||
|
|
||||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMaxRows() throws SQLException {
|
public int getMaxRows() throws SQLException {
|
||||||
|
if (isClosed())
|
||||||
|
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
||||||
// always set maxRows to zero, meaning unlimitted rows in a resultSet
|
// always set maxRows to zero, meaning unlimitted rows in a resultSet
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@ import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class RestfulStatement implements Statement {
|
public class RestfulStatement implements Statement {
|
||||||
|
|
||||||
private static final String STATEMENT_CLOSED = "Statement already closed.";
|
|
||||||
private boolean closed;
|
private boolean closed;
|
||||||
private String database;
|
private String database;
|
||||||
private final RestfulConnection conn;
|
private final RestfulConnection conn;
|
||||||
|
@ -131,14 +130,14 @@ public class RestfulStatement implements Statement {
|
||||||
@Override
|
@Override
|
||||||
public int getMaxFieldSize() throws SQLException {
|
public int getMaxFieldSize() throws SQLException {
|
||||||
if (isClosed())
|
if (isClosed())
|
||||||
throw new SQLException(STATEMENT_CLOSED);
|
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
||||||
return TSDBConstants.maxFieldSize;
|
return TSDBConstants.maxFieldSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setMaxFieldSize(int max) throws SQLException {
|
public void setMaxFieldSize(int max) throws SQLException {
|
||||||
if (isClosed())
|
if (isClosed())
|
||||||
throw new SQLException(STATEMENT_CLOSED);
|
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
||||||
if (max < 0)
|
if (max < 0)
|
||||||
throw new SQLException(TSDBConstants.INVALID_VARIABLES);
|
throw new SQLException(TSDBConstants.INVALID_VARIABLES);
|
||||||
// nothing to do
|
// nothing to do
|
||||||
|
@ -147,14 +146,14 @@ public class RestfulStatement implements Statement {
|
||||||
@Override
|
@Override
|
||||||
public int getMaxRows() throws SQLException {
|
public int getMaxRows() throws SQLException {
|
||||||
if (isClosed())
|
if (isClosed())
|
||||||
throw new SQLException(STATEMENT_CLOSED);
|
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setMaxRows(int max) throws SQLException {
|
public void setMaxRows(int max) throws SQLException {
|
||||||
if (isClosed())
|
if (isClosed())
|
||||||
throw new SQLException(STATEMENT_CLOSED);
|
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
||||||
if (max < 0)
|
if (max < 0)
|
||||||
throw new SQLException(TSDBConstants.INVALID_VARIABLES);
|
throw new SQLException(TSDBConstants.INVALID_VARIABLES);
|
||||||
// nothing to do
|
// nothing to do
|
||||||
|
@ -163,20 +162,20 @@ public class RestfulStatement implements Statement {
|
||||||
@Override
|
@Override
|
||||||
public void setEscapeProcessing(boolean enable) throws SQLException {
|
public void setEscapeProcessing(boolean enable) throws SQLException {
|
||||||
if (isClosed())
|
if (isClosed())
|
||||||
throw new SQLException(RestfulStatement.STATEMENT_CLOSED);
|
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getQueryTimeout() throws SQLException {
|
public int getQueryTimeout() throws SQLException {
|
||||||
if (isClosed())
|
if (isClosed())
|
||||||
throw new SQLException(STATEMENT_CLOSED);
|
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setQueryTimeout(int seconds) throws SQLException {
|
public void setQueryTimeout(int seconds) throws SQLException {
|
||||||
if (isClosed())
|
if (isClosed())
|
||||||
throw new SQLException(STATEMENT_CLOSED);
|
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
||||||
if (seconds < 0)
|
if (seconds < 0)
|
||||||
throw new SQLException(TSDBConstants.INVALID_VARIABLES);
|
throw new SQLException(TSDBConstants.INVALID_VARIABLES);
|
||||||
}
|
}
|
||||||
|
@ -189,7 +188,7 @@ public class RestfulStatement implements Statement {
|
||||||
@Override
|
@Override
|
||||||
public SQLWarning getWarnings() throws SQLException {
|
public SQLWarning getWarnings() throws SQLException {
|
||||||
if (isClosed())
|
if (isClosed())
|
||||||
throw new SQLException(STATEMENT_CLOSED);
|
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,13 +196,13 @@ public class RestfulStatement implements Statement {
|
||||||
public void clearWarnings() throws SQLException {
|
public void clearWarnings() throws SQLException {
|
||||||
// nothing to do
|
// nothing to do
|
||||||
if (isClosed())
|
if (isClosed())
|
||||||
throw new SQLException(STATEMENT_CLOSED);
|
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCursorName(String name) throws SQLException {
|
public void setCursorName(String name) throws SQLException {
|
||||||
if (isClosed())
|
if (isClosed())
|
||||||
throw new SQLException(RestfulStatement.STATEMENT_CLOSED);
|
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
||||||
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,7 +242,7 @@ public class RestfulStatement implements Statement {
|
||||||
@Override
|
@Override
|
||||||
public ResultSet getResultSet() throws SQLException {
|
public ResultSet getResultSet() throws SQLException {
|
||||||
if (isClosed())
|
if (isClosed())
|
||||||
throw new SQLException(STATEMENT_CLOSED);
|
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
||||||
return resultSet;
|
return resultSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,7 +274,7 @@ public class RestfulStatement implements Statement {
|
||||||
@Override
|
@Override
|
||||||
public void setFetchSize(int rows) throws SQLException {
|
public void setFetchSize(int rows) throws SQLException {
|
||||||
if (isClosed())
|
if (isClosed())
|
||||||
throw new SQLException(STATEMENT_CLOSED);
|
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
||||||
if (rows < 0)
|
if (rows < 0)
|
||||||
throw new SQLException(TSDBConstants.INVALID_VARIABLES);
|
throw new SQLException(TSDBConstants.INVALID_VARIABLES);
|
||||||
//nothing to do
|
//nothing to do
|
||||||
|
@ -284,28 +283,28 @@ public class RestfulStatement implements Statement {
|
||||||
@Override
|
@Override
|
||||||
public int getFetchSize() throws SQLException {
|
public int getFetchSize() throws SQLException {
|
||||||
if (isClosed())
|
if (isClosed())
|
||||||
throw new SQLException(STATEMENT_CLOSED);
|
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getResultSetConcurrency() throws SQLException {
|
public int getResultSetConcurrency() throws SQLException {
|
||||||
if (isClosed())
|
if (isClosed())
|
||||||
throw new SQLException(STATEMENT_CLOSED);
|
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
||||||
return this.resultSet.getConcurrency();
|
return this.resultSet.getConcurrency();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getResultSetType() throws SQLException {
|
public int getResultSetType() throws SQLException {
|
||||||
if (isClosed())
|
if (isClosed())
|
||||||
throw new SQLException(STATEMENT_CLOSED);
|
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
||||||
return this.resultSet.getType();
|
return this.resultSet.getType();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addBatch(String sql) throws SQLException {
|
public void addBatch(String sql) throws SQLException {
|
||||||
if (isClosed())
|
if (isClosed())
|
||||||
throw new SQLException(STATEMENT_CLOSED);
|
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
||||||
//TODO:
|
//TODO:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,14 +322,14 @@ public class RestfulStatement implements Statement {
|
||||||
@Override
|
@Override
|
||||||
public Connection getConnection() throws SQLException {
|
public Connection getConnection() throws SQLException {
|
||||||
if (isClosed())
|
if (isClosed())
|
||||||
throw new SQLException(STATEMENT_CLOSED);
|
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
||||||
return this.conn;
|
return this.conn;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getMoreResults(int current) throws SQLException {
|
public boolean getMoreResults(int current) throws SQLException {
|
||||||
if (isClosed())
|
if (isClosed())
|
||||||
throw new SQLException(STATEMENT_CLOSED);
|
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
||||||
if (resultSet == null)
|
if (resultSet == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -388,7 +387,7 @@ public class RestfulStatement implements Statement {
|
||||||
@Override
|
@Override
|
||||||
public int getResultSetHoldability() throws SQLException {
|
public int getResultSetHoldability() throws SQLException {
|
||||||
if (isClosed())
|
if (isClosed())
|
||||||
throw new SQLException(STATEMENT_CLOSED);
|
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
||||||
return this.resultSet.getHoldability();
|
return this.resultSet.getHoldability();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -400,28 +399,28 @@ public class RestfulStatement implements Statement {
|
||||||
@Override
|
@Override
|
||||||
public void setPoolable(boolean poolable) throws SQLException {
|
public void setPoolable(boolean poolable) throws SQLException {
|
||||||
if (isClosed())
|
if (isClosed())
|
||||||
throw new SQLException(STATEMENT_CLOSED);
|
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
||||||
//nothing to do
|
//nothing to do
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isPoolable() throws SQLException {
|
public boolean isPoolable() throws SQLException {
|
||||||
if (isClosed())
|
if (isClosed())
|
||||||
throw new SQLException(STATEMENT_CLOSED);
|
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void closeOnCompletion() throws SQLException {
|
public void closeOnCompletion() throws SQLException {
|
||||||
if (isClosed())
|
if (isClosed())
|
||||||
throw new SQLException(STATEMENT_CLOSED);
|
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
||||||
this.closeOnCompletion = true;
|
this.closeOnCompletion = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCloseOnCompletion() throws SQLException {
|
public boolean isCloseOnCompletion() throws SQLException {
|
||||||
if (isClosed())
|
if (isClosed())
|
||||||
throw new SQLException(STATEMENT_CLOSED);
|
throw new SQLException(TSDBConstants.STATEMENT_CLOSED);
|
||||||
return this.closeOnCompletion;
|
return this.closeOnCompletion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class StatementTest {
|
||||||
assertEquals(false, isClosed);
|
assertEquals(false, isClosed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = SQLFeatureNotSupportedException.class)
|
@Test(expected = SQLException.class)
|
||||||
public void testUnsupport() {
|
public void testUnsupport() {
|
||||||
try {
|
try {
|
||||||
Assert.assertNotNull(statement.unwrap(TSDBStatement.class));
|
Assert.assertNotNull(statement.unwrap(TSDBStatement.class));
|
||||||
|
|
Loading…
Reference in New Issue