Skip to content

Commit

Permalink
(#28) Some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
svettwer committed Apr 17, 2019
1 parent bf84552 commit cac5e0f
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@
import java.util.TreeMap;
import java.util.stream.Collectors;

/**
* @author Christoph Deppisch
*/

public class JdbcPreparedStatement extends JdbcStatement implements PreparedStatement {

/** The prepared statement to be executed */
Expand All @@ -67,19 +65,19 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat

private LobUtils lobUtils = new LobUtils();

public JdbcPreparedStatement(final HttpClient httpClient,
final String preparedStatement,
final String serverUrl,
final JdbcConnection connection) {
JdbcPreparedStatement(final HttpClient httpClient,
final String preparedStatement,
final String serverUrl,
final JdbcConnection connection) {
super(httpClient, serverUrl, connection);
this.preparedStatement = preparedStatement;
}

public JdbcPreparedStatement(final HttpClient httpClient,
final String preparedStatement,
final String serverUrl,
final JdbcConnection connection,
final LobUtils lobUtils) {
JdbcPreparedStatement(final HttpClient httpClient,
final String preparedStatement,
final String serverUrl,
final JdbcConnection connection,
final LobUtils lobUtils) {
this(httpClient, preparedStatement, serverUrl, connection);
this.lobUtils = lobUtils;
}
Expand All @@ -95,102 +93,102 @@ public int executeUpdate() throws SQLException {
}

@Override
public void setNull(final int parameterIndex, final int sqlType) throws SQLException {
public void setNull(final int parameterIndex, final int sqlType) {
setParameter(parameterIndex, null);
}

@Override
public void setBoolean(final int parameterIndex, final boolean x) throws SQLException {
public void setBoolean(final int parameterIndex, final boolean x) {
setParameter(parameterIndex, x);
}

@Override
public void setByte(final int parameterIndex, final byte x) throws SQLException {
public void setByte(final int parameterIndex, final byte x) {
setParameter(parameterIndex, x);
}

@Override
public void setShort(final int parameterIndex, final short x) throws SQLException {
public void setShort(final int parameterIndex, final short x) {
setParameter(parameterIndex, x);
}

@Override
public void setInt(final int parameterIndex, final int x) throws SQLException {
public void setInt(final int parameterIndex, final int x) {
setParameter(parameterIndex, x);
}

@Override
public void setLong(final int parameterIndex, final long x) throws SQLException {
public void setLong(final int parameterIndex, final long x) {
setParameter(parameterIndex, x);
}

@Override
public void setFloat(final int parameterIndex, final float x) throws SQLException {
public void setFloat(final int parameterIndex, final float x) {
setParameter(parameterIndex, x);
}

@Override
public void setDouble(final int parameterIndex, final double x) throws SQLException {
public void setDouble(final int parameterIndex, final double x) {
setParameter(parameterIndex, x);
}

@Override
public void setBigDecimal(final int parameterIndex, final BigDecimal x) throws SQLException {
public void setBigDecimal(final int parameterIndex, final BigDecimal x) {
setParameter(parameterIndex, x);
}

@Override
public void setString(final int parameterIndex, final String x) throws SQLException {
public void setString(final int parameterIndex, final String x) {
setParameter(parameterIndex, x);
}

@Override
public void setBytes(final int parameterIndex, final byte[] x) throws SQLException {
public void setBytes(final int parameterIndex, final byte[] x) {
setParameter(parameterIndex, x);
}

@Override
public void setDate(final int parameterIndex, final Date x) throws SQLException {
public void setDate(final int parameterIndex, final Date x) {
setParameter(parameterIndex, x);
}

@Override
public void setTime(final int parameterIndex, final Time x) throws SQLException {
public void setTime(final int parameterIndex, final Time x) {
setParameter(parameterIndex, x);
}

@Override
public void setTimestamp(final int parameterIndex, final Timestamp x) throws SQLException {
public void setTimestamp(final int parameterIndex, final Timestamp x) {
setParameter(parameterIndex, x);
}

@Override
public void setAsciiStream(final int parameterIndex, final InputStream x, final int length) throws SQLException {
public void setAsciiStream(final int parameterIndex, final InputStream x, final int length) {
setParameter(parameterIndex, x);
}

@Override
public void setUnicodeStream(final int parameterIndex, final InputStream x, final int length) throws SQLException {
public void setUnicodeStream(final int parameterIndex, final InputStream x, final int length) {
setParameter(parameterIndex, x);
}

@Override
public void setBinaryStream(final int parameterIndex, final InputStream x, final int length) throws SQLException {
public void setBinaryStream(final int parameterIndex, final InputStream x, final int length) {
setParameter(parameterIndex, x);
}

@Override
public void clearParameters() throws SQLException {
public void clearParameters() {
parameters.clear();
}

@Override
public void setObject(final int parameterIndex, final Object x, final int targetSqlType) throws SQLException {
public void setObject(final int parameterIndex, final Object x, final int targetSqlType) {
setParameter(parameterIndex, x);
}

@Override
public void setObject(final int parameterIndex, final Object x) throws SQLException {
public void setObject(final int parameterIndex, final Object x) {
setParameter(parameterIndex, x);
}

Expand Down Expand Up @@ -246,47 +244,47 @@ public void setArray(final int parameterIndex, final Array x) throws SQLExceptio
}

@Override
public ResultSetMetaData getMetaData() throws SQLException {
public ResultSetMetaData getMetaData() {
return resultSet.getMetaData();
}

@Override
public void setDate(final int parameterIndex, final Date x, final Calendar cal) throws SQLException {
public void setDate(final int parameterIndex, final Date x, final Calendar cal) {
setParameter(parameterIndex, x.toString());
}

@Override
public void setTime(final int parameterIndex, final Time x, final Calendar cal) throws SQLException {
public void setTime(final int parameterIndex, final Time x, final Calendar cal) {
setParameter(parameterIndex, x.getTime());
}

@Override
public void setTimestamp(final int parameterIndex, final Timestamp x, final Calendar cal) throws SQLException {
public void setTimestamp(final int parameterIndex, final Timestamp x, final Calendar cal) {
setParameter(parameterIndex, x.getTime());
}

@Override
public void setNull(final int parameterIndex, final int sqlType, final String typeName) throws SQLException {
public void setNull(final int parameterIndex, final int sqlType, final String typeName) {
setParameter(parameterIndex, null);
}

@Override
public void setURL(final int parameterIndex, final URL x) throws SQLException {
public void setURL(final int parameterIndex, final URL x) {
setParameter(parameterIndex, x);
}

@Override
public ParameterMetaData getParameterMetaData() throws SQLException {
public ParameterMetaData getParameterMetaData() {
return null;
}

@Override
public void setRowId(final int parameterIndex, final RowId x) throws SQLException {
public void setRowId(final int parameterIndex, final RowId x) {
setParameter(parameterIndex, x);
}

@Override
public void setNString(final int parameterIndex, final String x) throws SQLException {
public void setNString(final int parameterIndex, final String x) {
setParameter(parameterIndex, x);
}

Expand Down Expand Up @@ -327,7 +325,7 @@ public void setSQLXML(final int parameterIndex, final SQLXML xmlObject) throws S
}

@Override
public void setObject(final int parameterIndex, final Object x, final int targetSqlType, final int scaleOrLength) throws SQLException {
public void setObject(final int parameterIndex, final Object x, final int targetSqlType, final int scaleOrLength) {
setParameter(parameterIndex, x);
}

Expand Down
32 changes: 16 additions & 16 deletions driver/src/main/java/com/consol/citrus/db/driver/JdbcStatement.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public int getMaxFieldSize() throws SQLException {
}

@Override
public void setMaxFieldSize(final int max) throws SQLException {
public void setMaxFieldSize(final int max) {
//currently not required
}

Expand All @@ -181,12 +181,12 @@ public int getMaxRows() throws SQLException {
}

@Override
public void setMaxRows(final int max) throws SQLException {
public void setMaxRows(final int max) {
//currently not required
}

@Override
public void setEscapeProcessing(final boolean enable) throws SQLException {
public void setEscapeProcessing(final boolean enable) {
//currently not required
}

Expand All @@ -196,7 +196,7 @@ public int getQueryTimeout() throws SQLException {
}

@Override
public void setQueryTimeout(final int seconds) throws SQLException {
public void setQueryTimeout(final int seconds) {
//currently not required
}

Expand All @@ -206,7 +206,7 @@ public void cancel() throws SQLException {
}

@Override
public SQLWarning getWarnings() throws SQLException {
public SQLWarning getWarnings() {
return null;
}

Expand All @@ -216,28 +216,28 @@ public void clearWarnings() throws SQLException {
}

@Override
public void setCursorName(final String name) throws SQLException {
public void setCursorName(final String name) {
//currently not required
}

@Override
public java.sql.ResultSet getResultSet() throws SQLException {
public java.sql.ResultSet getResultSet() {
return resultSet;
}

@Override
public int getUpdateCount() throws SQLException {
public int getUpdateCount() {
return updateCount;
}

@Override
public boolean getMoreResults() throws SQLException {
public boolean getMoreResults() {
//Multiple results in one statement are currently not supported
return false;
}

@Override
public void setFetchDirection(final int direction) throws SQLException {
public void setFetchDirection(final int direction) {
//currently not required
}

Expand All @@ -247,7 +247,7 @@ public int getFetchDirection() throws SQLException {
}

@Override
public void setFetchSize(final int rows) throws SQLException {
public void setFetchSize(final int rows) {
//currently not required
}

Expand Down Expand Up @@ -289,7 +289,7 @@ public int[] executeBatch() throws SQLException {
}

@Override
public Connection getConnection() throws SQLException {
public Connection getConnection() {
return connection;
}

Expand Down Expand Up @@ -339,12 +339,12 @@ public int getResultSetHoldability() throws SQLException {
}

@Override
public boolean isClosed() throws SQLException {
public boolean isClosed() {
return closed;
}

@Override
public void setPoolable(final boolean poolable) throws SQLException {
public void setPoolable(final boolean poolable) {
//currently not required
}

Expand All @@ -369,7 +369,7 @@ public long getLargeUpdateCount() throws SQLException {
}

@Override
public void setLargeMaxRows(final long max) throws SQLException {
public void setLargeMaxRows(final long max) {
//currently not required
}

Expand Down Expand Up @@ -419,7 +419,7 @@ private DatabaseResult getDatabaseResult(final HttpResponse response) throws IOE
return objectMapper.readValue(response.getEntity().getContent(), DatabaseResult.class);
}

private void closeResultSet() throws SQLException {
private void closeResultSet() {
if(resultSet != null){
resultSet.close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
@SuppressWarnings({"SqlDialectInspection", "SqlNoDataSourceInspection"})
public class JdbcPreparedStatementTest {

private HttpClient httpClientMock = mock(HttpClient.class);
private JdbcConnection jdbcConnectionMock = mock(JdbcConnection.class);
private final HttpClient httpClientMock = mock(HttpClient.class);
private final JdbcConnection jdbcConnectionMock = mock(JdbcConnection.class);
private LobUtils lobUtils;

private JdbcPreparedStatement jdbcPreparedStatement;
Expand Down

0 comments on commit cac5e0f

Please sign in to comment.