You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/06/16 07:13:00 UTC
[GitHub] [shardingsphere] erichll opened a new issue #6069: When use PreparedStatement.setMaxRows(1) and Connection.setAutoCommit(false) at JDBC's API, throw java.sql.SQLException: 2Unknown exception: [Failed to switch schema, please terminate current transaction.]
erichll opened a new issue #6069:
URL: https://github.com/apache/shardingsphere/issues/6069
## Bug Report
When use PreparedStatement.setMaxRows(1) at JDBC's API, throw java.sql.SQLException: 2Unknown exception: [Failed to switch schema, please terminate current transaction.]
```java
Class.forName("com.mysql.jdbc.Driver");
try (Connection conn = DriverManager.getConnection("jdbc:mysql://......", "......", "......")) {
conn.setAutoCommit(false);
PreparedStatement psmt = conn.prepareStatement("select 1");
psmt.setMaxRows(1);
psmt.setMaxFieldSize(1);
ResultSet rs = psmt.executeQuery();
System.out.println(rs.next());
conn.commit();
}
```
### Which version of ShardingSphere did you use?
Mysql version: 5.7.21
Shardingproxy version: 4.1.1
### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
ShardingSphere-Proxy
### Example codes for reproduce this issue
1.java.sql.SQLException: 2Unknown exception: [Failed to switch schema, please terminate current transaction.]
```java
conn.setAutoCommit(false);
PreparedStatement psmt = conn.prepareStatement("select 1");
psmt.setMaxRows(1);
psmt.setMaxFieldSize(1);
ResultSet rs = psmt.executeQuery();
System.out.println(rs.next());
conn.commit();
```
1. The following code executes correctly
```
conn.setAutoCommit(false);
PreparedStatement psmt = conn.prepareStatement("select 1");
// psmt.setMaxRows(1);
psmt.setMaxFieldSize(1);
ResultSet rs = psmt.executeQuery();
System.out.println(rs.next());
conn.commit();
```
1. The following code executes correctly
```java
// conn.setAutoCommit(false);
PreparedStatement psmt = conn.prepareStatement("select 1");
psmt.setMaxRows(1);
psmt.setMaxFieldSize(1);
ResultSet rs = psmt.executeQuery();
System.out.println(rs.next());
// conn.commit();
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] cherrylzhao commented on issue #6069: When use PreparedStatement.setMaxRows(1) and Connection.setAutoCommit(false) at JDBC's API, throw java.sql.SQLException: 2Unknown exception: [Failed to switch schema, please terminate current transaction.]
Posted by GitBox <gi...@apache.org>.
cherrylzhao commented on issue #6069:
URL: https://github.com/apache/shardingsphere/issues/6069#issuecomment-644635083
similar with #5531
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] terrymanu closed issue #6069: When use PreparedStatement.setMaxRows(1) and Connection.setAutoCommit(false) at JDBC's API, throw java.sql.SQLException: 2Unknown exception: [Failed to switch schema, please terminate current transaction.]
Posted by GitBox <gi...@apache.org>.
terrymanu closed issue #6069:
URL: https://github.com/apache/shardingsphere/issues/6069
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org