-
Notifications
You must be signed in to change notification settings - Fork 556
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhance exception handling along with largeMaxRows and largeUpdateCou…
…nt support
- Loading branch information
Showing
10 changed files
with
921 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
153 changes: 153 additions & 0 deletions
153
clickhouse-jdbc/src/main/java/com/clickhouse/jdbc/internal/AbstractPreparedStatement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
package com.clickhouse.jdbc.internal; | ||
|
||
import java.sql.PreparedStatement; | ||
import java.sql.ResultSet; | ||
import java.sql.SQLException; | ||
|
||
import com.clickhouse.client.ClickHouseRequest; | ||
import com.clickhouse.jdbc.SqlExceptionUtils; | ||
|
||
public abstract class AbstractPreparedStatement extends ClickHouseStatementImpl implements PreparedStatement { | ||
protected AbstractPreparedStatement(ClickHouseConnectionImpl connection, ClickHouseRequest<?> request, | ||
int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { | ||
super(connection, request, resultSetType, resultSetConcurrency, resultSetHoldability); | ||
} | ||
|
||
protected abstract long[] executeAny(boolean asBatch) throws SQLException; | ||
|
||
@Override | ||
public final void addBatch(String sql) throws SQLException { | ||
ensureOpen(); | ||
|
||
throw SqlExceptionUtils | ||
.unsupportedError( | ||
"addBatch(String) cannot be called in PreparedStatement or CallableStatement!"); | ||
} | ||
|
||
@Override | ||
public final boolean execute(String sql) throws SQLException { | ||
ensureOpen(); | ||
|
||
throw SqlExceptionUtils | ||
.unsupportedError( | ||
"execute(String) cannot be called in PreparedStatement or CallableStatement!"); | ||
} | ||
|
||
@Override | ||
public final boolean execute(String sql, int autoGeneratedKeys) throws SQLException { | ||
ensureOpen(); | ||
|
||
throw SqlExceptionUtils | ||
.unsupportedError( | ||
"execute(String, int) cannot be called in PreparedStatement or CallableStatement!"); | ||
} | ||
|
||
@Override | ||
public final boolean execute(String sql, int[] columnIndexes) throws SQLException { | ||
ensureOpen(); | ||
|
||
throw SqlExceptionUtils | ||
.unsupportedError( | ||
"execute(String, int[]) cannot be called in PreparedStatement or CallableStatement!"); | ||
} | ||
|
||
@Override | ||
public final boolean execute(String sql, String[] columnNames) throws SQLException { | ||
ensureOpen(); | ||
|
||
throw SqlExceptionUtils | ||
.unsupportedError( | ||
"execute(String, String[]) cannot be called in PreparedStatement or CallableStatement!"); | ||
} | ||
|
||
@Override | ||
public long[] executeLargeBatch() throws SQLException { | ||
return executeAny(true); | ||
} | ||
|
||
@Override | ||
public final long executeLargeUpdate(String sql) throws SQLException { | ||
ensureOpen(); | ||
|
||
throw SqlExceptionUtils | ||
.unsupportedError( | ||
"executeLargeUpdate(String) cannot be called in PreparedStatement or CallableStatement!"); | ||
} | ||
|
||
@Override | ||
public final long executeLargeUpdate(String sql, int autoGeneratedKeys) throws SQLException { | ||
ensureOpen(); | ||
|
||
throw SqlExceptionUtils | ||
.unsupportedError( | ||
"executeLargeUpdate(String, int) cannot be called in PreparedStatement or CallableStatement!"); | ||
} | ||
|
||
@Override | ||
public final long executeLargeUpdate(String sql, int[] columnIndexes) throws SQLException { | ||
ensureOpen(); | ||
|
||
throw SqlExceptionUtils | ||
.unsupportedError( | ||
"executeLargeUpdate(String, int[]) cannot be called in PreparedStatement or CallableStatement!"); | ||
} | ||
|
||
@Override | ||
public final long executeLargeUpdate(String sql, String[] columnNames) throws SQLException { | ||
ensureOpen(); | ||
|
||
throw SqlExceptionUtils | ||
.unsupportedError( | ||
"executeLargeUpdate(String, String[]) cannot be called in PreparedStatement or CallableStatement!"); | ||
} | ||
|
||
@Override | ||
public final ResultSet executeQuery(String sql) throws SQLException { | ||
ensureOpen(); | ||
|
||
throw SqlExceptionUtils | ||
.unsupportedError( | ||
"executeQuery(String) cannot be called in PreparedStatement or CallableStatement!"); | ||
} | ||
|
||
@Override | ||
public final int executeUpdate() throws SQLException { | ||
return (int) executeLargeUpdate(); | ||
} | ||
|
||
@Override | ||
public final int executeUpdate(String sql) throws SQLException { | ||
ensureOpen(); | ||
|
||
throw SqlExceptionUtils | ||
.unsupportedError( | ||
"executeUpate(String) cannot be called in PreparedStatement or CallableStatement!"); | ||
} | ||
|
||
@Override | ||
public final int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException { | ||
ensureOpen(); | ||
|
||
throw SqlExceptionUtils | ||
.unsupportedError( | ||
"executeUpdate(String, int) cannot be called in PreparedStatement or CallableStatement!"); | ||
} | ||
|
||
@Override | ||
public final int executeUpdate(String sql, int[] columnIndexes) throws SQLException { | ||
ensureOpen(); | ||
|
||
throw SqlExceptionUtils | ||
.unsupportedError( | ||
"executeUpdate(String, int[]) cannot be called in PreparedStatement or CallableStatement!"); | ||
} | ||
|
||
@Override | ||
public final int executeUpdate(String sql, String[] columnNames) throws SQLException { | ||
ensureOpen(); | ||
|
||
throw SqlExceptionUtils | ||
.unsupportedError( | ||
"executeUpdate(String, String[]) cannot be called in PreparedStatement or CallableStatement!"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.