Skip to content

Commit 80991e1

Browse files
authored
Fix Statement.getUpdateCount() to return -1 when current result is a ResultSet (#54)
1 parent 1570ac6 commit 80991e1

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/LibSqlStatement.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,21 +121,29 @@ public ResultSet getResultSet() throws SQLException {
121121
@Override
122122
public int getUpdateCount() throws SQLException {
123123
if (executionResult == null) {
124-
throw new LibSqlException("No update count before statement execute");
124+
return -1;
125+
}
126+
if (executionResult.getColumns() != null && !executionResult.getColumns().isEmpty()) {
127+
return -1;
125128
}
126129
return (int) executionResult.getUpdateCount();
127130
}
128131

129132
@Override
130133
public long getLargeUpdateCount() throws SQLException {
131134
if (executionResult == null) {
132-
throw new LibSqlException("No update count before statement execute");
135+
return -1;
136+
}
137+
if (executionResult.getColumns() != null && !executionResult.getColumns().isEmpty()) {
138+
return -1;
133139
}
134140
return executionResult.getUpdateCount();
135141
}
136142

137143
@Override
138144
public boolean getMoreResults() throws SQLException {
145+
executionResult = null;
146+
resultSet = null;
139147
return false;
140148
}
141149

@@ -151,6 +159,8 @@ public int getFetchDirection() throws SQLException {
151159

152160
@Override
153161
public boolean getMoreResults(int current) throws SQLException {
162+
executionResult = null;
163+
resultSet = null;
154164
return false;
155165
}
156166
@Override

0 commit comments

Comments
 (0)