本文整理汇总了Java中com.mysql.jdbc.ParameterBindings类的典型用法代码示例。如果您正苦于以下问题:Java ParameterBindings类的具体用法?Java ParameterBindings怎么用?Java ParameterBindings使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ParameterBindings类属于com.mysql.jdbc包,在下文中一共展示了ParameterBindings类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: preProcess
import com.mysql.jdbc.ParameterBindings; //导入依赖的package包/类
@Override
public ResultSetInternalMethods preProcess(String sql, com.mysql.jdbc.Statement interceptedStatement, com.mysql.jdbc.Connection connection)
throws SQLException {
if (interceptedStatement instanceof com.mysql.jdbc.PreparedStatement) {
String asSql = interceptedStatement.toString();
int firstColon = asSql.indexOf(":");
asSql = asSql.substring(firstColon + 2);
if (asSql.equals(this.prevSql)) {
throw new RuntimeException("Previous statement matched current: " + sql);
}
this.prevSql = asSql;
ParameterBindings b = ((com.mysql.jdbc.PreparedStatement) interceptedStatement).getParameterBindings();
vals.add(new Integer(b.getInt(1)));
}
return null;
}
示例2: preProcess
import com.mysql.jdbc.ParameterBindings; //导入依赖的package包/类
public ResultSetInternalMethods preProcess(String sql, com.mysql.jdbc.Statement interceptedStatement, com.mysql.jdbc.Connection connection)
throws SQLException {
String asSql = sql;
if (interceptedStatement instanceof com.mysql.jdbc.PreparedStatement) {
asSql = interceptedStatement.toString();
int firstColon = asSql.indexOf(":");
asSql = asSql.substring(firstColon + 2);
if (asSql.equals(this.prevSql)) {
throw new RuntimeException("Previous statement matched current: " + sql);
}
this.prevSql = asSql;
ParameterBindings b = ((com.mysql.jdbc.PreparedStatement) interceptedStatement).getParameterBindings();
vals.add(new Integer(b.getInt(1)));
}
return null;
}
示例3: preProcess
import com.mysql.jdbc.ParameterBindings; //导入依赖的package包/类
public ResultSetInternalMethods preProcess(String sql,
com.mysql.jdbc.Statement interceptedStatement,
com.mysql.jdbc.Connection connection) throws SQLException {
String asSql = sql;
if (interceptedStatement instanceof com.mysql.jdbc.PreparedStatement) {
asSql = interceptedStatement.toString();
int firstColon = asSql.indexOf(":");
asSql = asSql.substring(firstColon + 2);
if (asSql.equals(prevSql))
throw new RuntimeException(
"Previous statement matched current: " + sql);
prevSql = asSql;
ParameterBindings b = ((com.mysql.jdbc.PreparedStatement) interceptedStatement)
.getParameterBindings();
vals.add(new Integer(b.getInt(1)));
}
return null;
}
示例4: testParameterBindings
import com.mysql.jdbc.ParameterBindings; //导入依赖的package包/类
public void testParameterBindings() throws Exception {
// Need to check character set stuff, so need a new connection
Connection utfConn = getConnectionWithProps("characterEncoding=utf-8,treatUtilDateAsTimestamp=false,autoDeserialize=true");
java.util.Date now = new java.util.Date();
Object[] valuesToTest = new Object[] { new Byte(Byte.MIN_VALUE), new Short(Short.MIN_VALUE), new Integer(Integer.MIN_VALUE), new Long(Long.MIN_VALUE),
new Double(Double.MIN_VALUE), "\u4E2D\u6587", new BigDecimal(Math.PI), null, // to test isNull
now // to test serialization
};
StringBuilder statementText = new StringBuilder("SELECT ?");
for (int i = 1; i < valuesToTest.length; i++) {
statementText.append(",?");
}
this.pstmt = utfConn.prepareStatement(statementText.toString());
for (int i = 0; i < valuesToTest.length; i++) {
this.pstmt.setObject(i + 1, valuesToTest[i]);
}
ParameterBindings bindings = ((com.mysql.jdbc.PreparedStatement) this.pstmt).getParameterBindings();
for (int i = 0; i < valuesToTest.length; i++) {
Object boundObject = bindings.getObject(i + 1);
if (boundObject == null || valuesToTest[i] == null) {
continue;
}
Class<?> boundObjectClass = boundObject.getClass();
Class<?> testObjectClass = valuesToTest[i].getClass();
if (boundObject instanceof Number) {
assertEquals("For binding #" + (i + 1) + " of class " + boundObjectClass + " compared to " + testObjectClass, boundObject.toString(),
valuesToTest[i].toString());
} else if (boundObject instanceof Date) {
} else {
assertEquals("For binding #" + (i + 1) + " of class " + boundObjectClass + " compared to " + testObjectClass, boundObject, valuesToTest[i]);
}
}
}
示例5: testParameterBindings
import com.mysql.jdbc.ParameterBindings; //导入依赖的package包/类
public void testParameterBindings() throws Exception {
// Need to check character set stuff, so need a new connection
Connection utfConn = getConnectionWithProps("characterEncoding=utf-8,treatUtilDateAsTimestamp=false,autoDeserialize=true");
java.util.Date now = new java.util.Date();
Object[] valuesToTest = new Object[] { new Byte(Byte.MIN_VALUE), new Short(Short.MIN_VALUE), new Integer(Integer.MIN_VALUE), new Long(Long.MIN_VALUE),
new Double(Double.MIN_VALUE), "\u4E2D\u6587", new BigDecimal(Math.PI), null, // to test isNull
now // to test serialization
};
StringBuilder statementText = new StringBuilder("SELECT ?");
for (int i = 1; i < valuesToTest.length; i++) {
statementText.append(",?");
}
this.pstmt = utfConn.prepareStatement(statementText.toString());
for (int i = 0; i < valuesToTest.length; i++) {
this.pstmt.setObject(i + 1, valuesToTest[i]);
}
ParameterBindings bindings = ((com.mysql.jdbc.PreparedStatement) this.pstmt).getParameterBindings();
for (int i = 0; i < valuesToTest.length; i++) {
Object boundObject = bindings.getObject(i + 1);
if (boundObject == null && valuesToTest[i] == null) {
continue;
}
Class<?> boundObjectClass = boundObject.getClass();
Class<?> testObjectClass = valuesToTest[i].getClass();
if (boundObject instanceof Number) {
assertEquals("For binding #" + (i + 1) + " of class " + boundObjectClass + " compared to " + testObjectClass, boundObject.toString(),
valuesToTest[i].toString());
} else if (boundObject instanceof Date) {
} else {
assertEquals("For binding #" + (i + 1) + " of class " + boundObjectClass + " compared to " + testObjectClass, boundObject, valuesToTest[i]);
}
}
}
示例6: testParameterBindings
import com.mysql.jdbc.ParameterBindings; //导入依赖的package包/类
public void testParameterBindings() throws Exception {
// Need to check character set stuff, so need a new connection
Connection utfConn = getConnectionWithProps("characterEncoding=utf-8,treatUtilDateAsTimestamp=false,autoDeserialize=true");
java.util.Date now = new java.util.Date();
Object[] valuesToTest = new Object[] {
new Byte(Byte.MIN_VALUE),
new Short(Short.MIN_VALUE),
new Integer(Integer.MIN_VALUE),
new Long(Long.MIN_VALUE),
new Double(Double.MIN_VALUE),
"\u4E2D\u6587",
new BigDecimal(Math.PI),
null, // to test isNull
now // to test serialization
};
StringBuffer statementText = new StringBuffer("SELECT ?");
for (int i = 1; i < valuesToTest.length; i++) {
statementText.append(",?");
}
this.pstmt = utfConn.prepareStatement(statementText.toString());
for (int i = 0; i < valuesToTest.length; i++) {
this.pstmt.setObject(i + 1, valuesToTest[i]);
}
ParameterBindings bindings = ((com.mysql.jdbc.PreparedStatement)this.pstmt).getParameterBindings();
for (int i = 0; i < valuesToTest.length; i++) {
Object boundObject = bindings.getObject(i + 1);
if (boundObject == null && valuesToTest[i] == null) {
continue;
}
Class<?> boundObjectClass= boundObject.getClass();
Class<?> testObjectClass = valuesToTest[i].getClass();
if (boundObject instanceof Number) {
assertEquals("For binding #" + (i + 1) + " of class " + boundObjectClass + " compared to " + testObjectClass, boundObject.toString(), valuesToTest[i].toString());
} else if (boundObject instanceof Date) {
} else {
assertEquals("For binding #" + (i + 1) + " of class " + boundObjectClass + " compared to " + testObjectClass, boundObject, valuesToTest[i]);
}
}
}
示例7: testParameterBindings
import com.mysql.jdbc.ParameterBindings; //导入依赖的package包/类
public void testParameterBindings() throws Exception {
// Need to check character set stuff, so need a new connection
Connection utfConn = getConnectionWithProps("characterEncoding=utf-8,treatUtilDateAsTimestamp=false,autoDeserialize=true");
java.util.Date now = new java.util.Date();
Object[] valuesToTest = new Object[] { new Byte(Byte.MIN_VALUE), new Short(Short.MIN_VALUE), new Integer(Integer.MIN_VALUE), new Long(Long.MIN_VALUE),
new Double(Double.MIN_VALUE), "\u4E2D\u6587", new BigDecimal(Math.PI), null, // to test isNull
now // to test serialization
};
StringBuffer statementText = new StringBuffer("SELECT ?");
for (int i = 1; i < valuesToTest.length; i++) {
statementText.append(",?");
}
this.pstmt = utfConn.prepareStatement(statementText.toString());
for (int i = 0; i < valuesToTest.length; i++) {
this.pstmt.setObject(i + 1, valuesToTest[i]);
}
ParameterBindings bindings = ((com.mysql.jdbc.PreparedStatement) this.pstmt).getParameterBindings();
for (int i = 0; i < valuesToTest.length; i++) {
Object boundObject = bindings.getObject(i + 1);
if (boundObject == null && valuesToTest[i] == null) {
continue;
}
Class<?> boundObjectClass = boundObject.getClass();
Class<?> testObjectClass = valuesToTest[i].getClass();
if (boundObject instanceof Number) {
assertEquals("For binding #" + (i + 1) + " of class " + boundObjectClass + " compared to " + testObjectClass, boundObject.toString(),
valuesToTest[i].toString());
} else if (boundObject instanceof Date) {
} else {
assertEquals("For binding #" + (i + 1) + " of class " + boundObjectClass + " compared to " + testObjectClass, boundObject, valuesToTest[i]);
}
}
}