-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updated rows is not returned #2802
base: master
Are you sure you want to change the base?
Conversation
In the PreparedStatementHandler the execute function is used and afterwards the getUpdateCount is used. However in my case (Sybase) the updateCount returns zero. The two statements can be combined to 1; executeUpdate which returns the correct result.
Hello @koekj , Changing to I just tested and the following test passes. import static org.junit.jupiter.api.Assertions.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;
import org.junit.jupiter.api.Test;
import net.harawata.jdbc.connection.JdbcConnection;
class SybaseTest {
@Test
void test() throws Exception {
Class.forName("com.sybase.jdbc42.jdbc.SybDriver");
String url = "jdbc:sybase:Tds:192.168.60.8:5000?serviceName=TEST";
String username = "xxx";
String password = "xxx";
try (Connection con = DriverManager.getConnection(url, username, password)) {
try (Statement st = con.createStatement()) {
st.execute("drop TABLE test ");
} catch (SQLException e) {
//
}
try (Statement st = con.createStatement()) {
st.execute("CREATE TABLE test (id int, t varchar(20))");
st.execute("insert into test (id, t) values (1, 'val')");
}
try (PreparedStatement stmt = con.prepareStatement("update test set t = ? where id = ?")) {
stmt.setString(1, "val2");
stmt.setInt(2, 1);
assertFalse(stmt.execute());
assertEquals(1, stmt.getUpdateCount());
}
}
}
}
|
Ok, I will check this; I'm using spring boot in combination with mybatis. |
Hi, |
Oh, by the way, if the issue is reproducible with a plain JDBC code (i.e. without MyBatis) like the one I posted, please paste it. |
I use an existing database where I'm not the "super user" so I have to see if I can setup a local database for reproduction. Did you use a docker image to get the database up and running as that would help me to speed up the reproduction. |
Last time checked, there was no official docker image, so I had to install express edition or something on my VirtualBox VM. |
Ok clear. I will do the same then. |
看到了, |
In the PreparedStatementHandler the execute function is used and afterwards the getUpdateCount is used. However in my case (Sybase) the updateCount returns zero. The two statements can be combined to 1; executeUpdate which returns the correct result.