本文整理汇总了Java中com.mysql.jdbc.ServerPreparedStatement类的典型用法代码示例。如果您正苦于以下问题:Java ServerPreparedStatement类的具体用法?Java ServerPreparedStatement怎么用?Java ServerPreparedStatement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ServerPreparedStatement类属于com.mysql.jdbc包,在下文中一共展示了ServerPreparedStatement类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: preProcess
import com.mysql.jdbc.ServerPreparedStatement; //导入依赖的package包/类
@Override
public ResultSetInternalMethods preProcess(String sql, com.mysql.jdbc.Statement interceptedStatement, com.mysql.jdbc.Connection connection)
throws SQLException {
if (!(interceptedStatement instanceof ServerPreparedStatement)) {
String query = sql;
if (query == null && interceptedStatement instanceof com.mysql.jdbc.PreparedStatement) {
query = interceptedStatement.toString();
query = query.substring(query.indexOf(':') + 2);
}
if (query != null
&& ((query.startsWith("INSERT") || query.startsWith("UPDATE") || query.startsWith("CALL")) && !query.contains("no_ts_trunk"))) {
if (this.sendFracSecs ^ query.contains(".999")) {
fail("Wrong TIMESTAMP trunctation in query [" + query + "]");
}
}
}
return super.preProcess(sql, interceptedStatement, connection);
}
示例2: testBug4718
import com.mysql.jdbc.ServerPreparedStatement; //导入依赖的package包/类
/**
* Server doesn't accept everything as a server-side prepared statement, so
* by default we scan for stuff it can't handle.
*
* @throws SQLException
*/
public void testBug4718() throws SQLException {
if (versionMeetsMinimum(4, 1, 0) && ((com.mysql.jdbc.Connection) this.conn).getUseServerPreparedStmts()) {
this.pstmt = this.conn.prepareStatement("SELECT 1 LIMIT ?");
assertTrue(this.pstmt instanceof com.mysql.jdbc.PreparedStatement);
this.pstmt = this.conn.prepareStatement("SELECT 1 LIMIT 1");
assertTrue(this.pstmt instanceof com.mysql.jdbc.ServerPreparedStatement);
this.pstmt = this.conn.prepareStatement("SELECT 1 LIMIT 1, ?");
assertTrue(this.pstmt instanceof com.mysql.jdbc.PreparedStatement);
try {
this.stmt.executeUpdate("DROP TABLE IF EXISTS testBug4718");
this.stmt.executeUpdate("CREATE TABLE testBug4718 (field1 char(32))");
this.pstmt = this.conn.prepareStatement("ALTER TABLE testBug4718 ADD INDEX (field1)");
assertTrue(this.pstmt instanceof com.mysql.jdbc.PreparedStatement);
this.pstmt = this.conn.prepareStatement("SELECT 1");
assertTrue(this.pstmt instanceof ServerPreparedStatement);
this.pstmt = this.conn.prepareStatement("UPDATE testBug4718 SET field1=1");
assertTrue(this.pstmt instanceof ServerPreparedStatement);
this.pstmt = this.conn.prepareStatement("UPDATE testBug4718 SET field1=1 LIMIT 1");
assertTrue(this.pstmt instanceof ServerPreparedStatement);
this.pstmt = this.conn.prepareStatement("UPDATE testBug4718 SET field1=1 LIMIT ?");
assertTrue(this.pstmt instanceof com.mysql.jdbc.PreparedStatement);
this.pstmt = this.conn.prepareStatement("UPDATE testBug4718 SET field1='Will we ignore LIMIT ?,?'");
assertTrue(this.pstmt instanceof ServerPreparedStatement);
} finally {
this.stmt.executeUpdate("DROP TABLE IF EXISTS testBug4718");
}
}
}
示例3: testBug81706
import com.mysql.jdbc.ServerPreparedStatement; //导入依赖的package包/类
/**
* Tests fix for Bug#81706 - NullPointerException in driver.
*/
public void testBug81706() throws Exception {
boolean useSPS = false;
boolean cacheRsMd = false;
boolean readOnly = false;
do {
final String testCase = String.format("Case [SPS: %s, CacheRsMd: %s, Read-only: %s]", useSPS ? "Y" : "N", cacheRsMd ? "Y" : "N",
readOnly ? "Y" : "N");
Properties props = new Properties();
props.setProperty("useServerPrepStmts", Boolean.toString(useSPS));
props.setProperty("cacheResultSetMetadata", Boolean.toString(cacheRsMd));
props.setProperty("statementInterceptors", TestBug81706StatementInterceptor.class.getName());
Connection testConn = getConnectionWithProps(props);
testConn.setReadOnly(readOnly);
Statement testStmt;
PreparedStatement testPstmt;
TestBug81706StatementInterceptor.isActive = true;
TestBug81706StatementInterceptor.testCase = testCase;
// Statement.executeQuery();
testStmt = testConn.createStatement();
testStmt.setFetchSize(Integer.MIN_VALUE);
testStmt.executeQuery("/* ping */");
testStmt.close();
// Statemente.execute();
testStmt = testConn.createStatement();
testStmt.setFetchSize(Integer.MIN_VALUE);
testStmt.execute("/* ping */");
testStmt.close();
// PreparedStatement.executeQuery();
testPstmt = testConn.prepareStatement("/* ping */");
assertFalse(testCase + ": Not the right Statement type.", testPstmt instanceof ServerPreparedStatement);
testPstmt.setFetchSize(Integer.MIN_VALUE);
testPstmt.executeQuery();
testPstmt.close();
// PreparedStatement.execute();
testPstmt = testConn.prepareStatement("/* ping */");
assertFalse(testCase + ": Not the right Statement type.", testPstmt instanceof ServerPreparedStatement);
testPstmt.setFetchSize(Integer.MIN_VALUE);
testPstmt.execute();
testPstmt.close();
TestBug81706StatementInterceptor.isActive = false;
testConn.close();
} while ((useSPS = !useSPS) || (cacheRsMd = !cacheRsMd) || (readOnly = !readOnly)); // Cycle through all possible combinations.
}
示例4: recachePreparedStatement
import com.mysql.jdbc.ServerPreparedStatement; //导入依赖的package包/类
public void recachePreparedStatement(ServerPreparedStatement pstmt) throws SQLException {
}
示例5: decachePreparedStatement
import com.mysql.jdbc.ServerPreparedStatement; //导入依赖的package包/类
public void decachePreparedStatement(ServerPreparedStatement pstmt) throws SQLException {
}
示例6: testBug4718
import com.mysql.jdbc.ServerPreparedStatement; //导入依赖的package包/类
/**
* Server doesn't accept everything as a server-side prepared statement, so
* by default we scan for stuff it can't handle.
*
* @throws SQLException
*/
public void testBug4718() throws SQLException {
if (versionMeetsMinimum(4, 1, 0)
&& ((com.mysql.jdbc.Connection) this.conn)
.getUseServerPreparedStmts()) {
this.pstmt = this.conn.prepareStatement("SELECT 1 LIMIT ?");
assertTrue(this.pstmt instanceof com.mysql.jdbc.PreparedStatement);
this.pstmt = this.conn.prepareStatement("SELECT 1 LIMIT 1");
assertTrue(this.pstmt instanceof com.mysql.jdbc.ServerPreparedStatement);
this.pstmt = this.conn.prepareStatement("SELECT 1 LIMIT 1, ?");
assertTrue(this.pstmt instanceof com.mysql.jdbc.PreparedStatement);
try {
this.stmt.executeUpdate("DROP TABLE IF EXISTS testBug4718");
this.stmt
.executeUpdate("CREATE TABLE testBug4718 (field1 char(32))");
this.pstmt = this.conn
.prepareStatement("ALTER TABLE testBug4718 ADD INDEX (field1)");
assertTrue(this.pstmt instanceof com.mysql.jdbc.PreparedStatement);
this.pstmt = this.conn.prepareStatement("SELECT 1");
assertTrue(this.pstmt instanceof ServerPreparedStatement);
this.pstmt = this.conn
.prepareStatement("UPDATE testBug4718 SET field1=1");
assertTrue(this.pstmt instanceof ServerPreparedStatement);
this.pstmt = this.conn
.prepareStatement("UPDATE testBug4718 SET field1=1 LIMIT 1");
assertTrue(this.pstmt instanceof ServerPreparedStatement);
this.pstmt = this.conn
.prepareStatement("UPDATE testBug4718 SET field1=1 LIMIT ?");
assertTrue(this.pstmt instanceof com.mysql.jdbc.PreparedStatement);
this.pstmt = this.conn
.prepareStatement("UPDATE testBug4718 SET field1='Will we ignore LIMIT ?,?'");
assertTrue(this.pstmt instanceof ServerPreparedStatement);
} finally {
this.stmt.executeUpdate("DROP TABLE IF EXISTS testBug4718");
}
}
}
示例7: recachePreparedStatement
import com.mysql.jdbc.ServerPreparedStatement; //导入依赖的package包/类
public void recachePreparedStatement(ServerPreparedStatement pstmt)
throws SQLException {
}
示例8: decachePreparedStatement
import com.mysql.jdbc.ServerPreparedStatement; //导入依赖的package包/类
public void decachePreparedStatement(ServerPreparedStatement pstmt)
throws SQLException {
}