当前位置: 首页>>代码示例>>Java>>正文


Java ParameterBindings类代码示例

本文整理汇总了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;
}
 
开发者ID:bragex,项目名称:the-vigilantes,代码行数:19,代码来源:StatementRegressionTest.java

示例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;
}
 
开发者ID:mniepert,项目名称:TPKB,代码行数:19,代码来源:StatementRegressionTest.java

示例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;
}
 
开发者ID:hinsenchan,项目名称:fil_project_mgmt_app_v2,代码行数:21,代码来源:StatementRegressionTest.java

示例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]);
        }
    }
}
 
开发者ID:bragex,项目名称:the-vigilantes,代码行数:46,代码来源:StatementsTest.java

示例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]);
        }
    }
}
 
开发者ID:mniepert,项目名称:TPKB,代码行数:46,代码来源:StatementsTest.java

示例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]);
        }
    }
}
 
开发者ID:hinsenchan,项目名称:fil_project_mgmt_app_v2,代码行数:52,代码来源:StatementsTest.java

示例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]);
        }
    }
}
 
开发者ID:BasThomas,项目名称:SMPT42,代码行数:46,代码来源:StatementsTest.java


注:本文中的com.mysql.jdbc.ParameterBindings类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。