Closed c-helios closed 3 years ago
@heysJava , the default behavior value of above three parameters are ResultSet.TYPE_FORWARD_ONLY
, ResultSet.CONCUR_READ_ONLY
, ResultSet.HOLD_CURSORS_OVER_COMMIT
. Users could specific the value of the parameters.
@heysJava , the default behavior value of above three parameters are ResultSet.TYPE_FORWARD_ONLY
, ResultSet.CONCUR_READ_ONLY
, ResultSet.HOLD_CURSORS_OVER_COMMIT
. Users could specific the value of the parameters.
@heysJava , the default behavior value of above three parameters are
ResultSet.TYPE_FORWARD_ONLY
,ResultSet.CONCUR_READ_ONLY
,ResultSet.HOLD_CURSORS_OVER_COMMIT
. Users could specific the value of the parameters.
@SteNicholas ,How do users specify these parameter values? When using the qurey method of jdbcTemplate, connection.createStatement() will be used. This method calls the createStatement() method in the ShardingSphereConnection class, and it will be new ShardingSphereStatement(this); that is this way public ShardingSphereStatement(final ShardingSphereConnection connection) { this(connection, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT); } These parameter values are fixed. When users want to use this method, they cannot pass custom parameter values. If you want to change this parameter value, you need to change the source code of jdbcTemplate or the source code of Shardingsphere. I feel that this method is very unfriendly. There is no other way to avoid
@heysJava Hi, I have checked the Connection implementation of MySQL JDBC driver. By default, similar parameter settings are also provided.
private static final int DEFAULT_RESULT_SET_TYPE = ResultSet.TYPE_FORWARD_ONLY;
private static final int DEFAULT_RESULT_SET_CONCURRENCY = ResultSet.CONCUR_READ_ONLY;
/**
* SQL statements without parameters are normally executed using Statement
* objects. If the same SQL statement is executed many times, it is more
* efficient to use a PreparedStatement
*
* @return a new Statement object
* @throws SQLException
* passed through from the constructor
*/
public java.sql.Statement createStatement() throws SQLException {
return createStatement(DEFAULT_RESULT_SET_TYPE, DEFAULT_RESULT_SET_CONCURRENCY);
}
Besides, the ShardingSphereConnection
class provides multiple createStatement overload methods to support user-specified parameters. I think you should check the Spring JdbcTemplate
documentation to see whether it provides relevant methods to call other overloaded methods.
@heysJava Hi, I have checked the Connection implementation of MySQL JDBC driver. By default, similar parameter settings are also provided.
private static final int DEFAULT_RESULT_SET_TYPE = ResultSet.TYPE_FORWARD_ONLY; private static final int DEFAULT_RESULT_SET_CONCURRENCY = ResultSet.CONCUR_READ_ONLY; /** * SQL statements without parameters are normally executed using Statement * objects. If the same SQL statement is executed many times, it is more * efficient to use a PreparedStatement * * @return a new Statement object * @throws SQLException * passed through from the constructor */ public java.sql.Statement createStatement() throws SQLException { return createStatement(DEFAULT_RESULT_SET_TYPE, DEFAULT_RESULT_SET_CONCURRENCY); }
Besides, the
ShardingSphereConnection
class provides multiple createStatement overload methods to support user-specified parameters. I think you should check the SpringJdbcTemplate
documentation to see whether it provides relevant methods to call other overloaded methods.
@heysJava, do you have other problem for ShardingSphereStatement
? If you have no question about this, please close this issue.
public ShardingSphereStatement(final ShardingSphereConnection connection) { this(connection, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT); }
Excuse me, why the three parameters are fixed in this method