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


Java CallableStatement类代码示例

本文整理汇总了Java中java.sql.CallableStatement的典型用法代码示例。如果您正苦于以下问题:Java CallableStatement类的具体用法?Java CallableStatement怎么用?Java CallableStatement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CallableStatement类属于java.sql包,在下文中一共展示了CallableStatement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testBug25379

import java.sql.CallableStatement; //导入依赖的package包/类
/**
 * Tests fix for BUG#25379 - INOUT parameters in CallableStatements get
 * doubly-escaped.
 * 
 * @throws Exception
 *             if the test fails.
 */
public void testBug25379() throws Exception {
    if (!serverSupportsStoredProcedures()) {
        return;
    }

    createTable("testBug25379", "(col char(40))");

    createProcedure("sp_testBug25379", "(INOUT invalue char(255))\nBEGIN" + "\ninsert into testBug25379(col) values(invalue);\nEND");

    CallableStatement cstmt = this.conn.prepareCall("{call sp_testBug25379(?)}");
    cstmt.setString(1, "'john'");
    cstmt.executeUpdate();
    assertEquals("'john'", cstmt.getString(1));
    assertEquals("'john'", getSingleValue("testBug25379", "col", "").toString());
}
 
开发者ID:JuanJoseFJ,项目名称:ProyectoPacientes,代码行数:23,代码来源:CallableStatementRegressionTest.java

示例2: _computeProxiedInterface

import java.sql.CallableStatement; //导入依赖的package包/类
/**
 * Given a delegate, retrieves the interface that must be implemented by a
 * surrogate dynamic proxy to ensure pooling sensitive methods
 * of the delegate are not exposed directly to clients.
 *
 * @param delegate the target delegate of interest
 * @return the interface that must be implemented by a surrogate dynamic
 *         proxy to ensure pooling sensitive methods of the delegate are
 *         not exposed directly to clients
 */
protected static Class[] _computeProxiedInterface(Object delegate) {

    // NOTE:  Order is important for XXXStatement.
    if (delegate instanceof Array) {
        return arrayInterface;
    } else if (delegate instanceof Connection) {
        return connectionInterface;
    } else if (delegate instanceof CallableStatement) {
        return callableStatementInterface;
    } else if (delegate instanceof DatabaseMetaData) {
        return databaseMetaDataInterface;
    } else if (delegate instanceof PreparedStatement) {
        return preparedStatementInterface;
    } else if (delegate instanceof ResultSet) {
        return resultSetInterface;
    } else if (delegate instanceof Statement) {
        return statementInterface;
    } else {
        return null;
    }
}
 
开发者ID:s-store,项目名称:s-store,代码行数:32,代码来源:WrapperInvocationHandler.java

示例3: lookupDefaultSchema

import java.sql.CallableStatement; //导入依赖的package包/类
private void lookupDefaultSchema(DatabaseMetaData databaseMetaData) {
	try {
		CallableStatement cstmt = null;
		try {
			cstmt = databaseMetaData.getConnection().prepareCall("{? = call sys_context('USERENV', 'CURRENT_SCHEMA')}");
			cstmt.registerOutParameter(1, Types.VARCHAR);
			cstmt.execute();
			this.defaultSchema = cstmt.getString(1);
		}
		finally {
			if (cstmt != null) {
				cstmt.close();
			}
		}
	}
	catch (Exception ignore) {
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:OracleTableMetaDataProvider.java

示例4: testBug22024

import java.sql.CallableStatement; //导入依赖的package包/类
/**
 * Tests fix for BUG#22024 - Newlines causing whitespace to span confuse
 * procedure parser when getting parameter metadata for stored procedures.
 * 
 * @throws Exception
 *             if the test fails
 */
public void testBug22024() throws Exception {
    if (!serverSupportsStoredProcedures()) {
        return;
    }

    createProcedure("testBug22024_1", "(\r\n)\r\n BEGIN SELECT 1; END");
    createProcedure("testBug22024_2", "(\r\na INT)\r\n BEGIN SELECT 1; END");

    CallableStatement cstmt = null;

    try {
        cstmt = this.conn.prepareCall("{CALL testBug22024_1()}");
        cstmt.execute();

        cstmt = this.conn.prepareCall("{CALL testBug22024_2(?)}");
        cstmt.setInt(1, 1);
        cstmt.execute();
    } finally {
        if (cstmt != null) {
            cstmt.close();
        }
    }

}
 
开发者ID:bragex,项目名称:the-vigilantes,代码行数:32,代码来源:CallableStatementRegressionTest.java

示例5: testBug21462

import java.sql.CallableStatement; //导入依赖的package包/类
/**
 * Tests fix for BUG#21462 - JDBC (and ODBC) specifications allow
 * no-parenthesis CALL statements for procedures with no arguments, MySQL
 * server does not.
 * 
 * @throws Exception
 *             if the test fails.
 */
public void testBug21462() throws Exception {
    if (!serverSupportsStoredProcedures()) {
        return;
    }

    createProcedure("testBug21462", "() BEGIN SELECT 1; END");

    CallableStatement cstmt = null;

    try {
        cstmt = this.conn.prepareCall("{CALL testBug21462}");
        cstmt.execute();
    } finally {
        if (cstmt != null) {
            cstmt.close();
        }
    }

}
 
开发者ID:Jugendhackt,项目名称:OpenVertretung,代码行数:28,代码来源:CallableStatementRegressionTest.java

示例6: testBug35199

import java.sql.CallableStatement; //导入依赖的package包/类
public void testBug35199() throws Exception {
    if (!versionMeetsMinimum(5, 0)) {
        return;
    }

    createFunction("test_function", "(a varchar(40), b bigint(20), c varchar(80)) RETURNS bigint(20) LANGUAGE SQL DETERMINISTIC "
            + "MODIFIES SQL DATA COMMENT 'bbb' BEGIN RETURN 1; END; ");

    CallableStatement callable = null;
    try {
        callable = this.conn.prepareCall("{? = call test_function(?,101,?)}");
        callable.registerOutParameter(1, Types.BIGINT);

        callable.setString(2, "FOO");
        callable.setString(3, "BAR");
        callable.executeUpdate();
    } finally {
        if (callable != null) {
            callable.close();
        }
    }
}
 
开发者ID:Jugendhackt,项目名称:OpenVertretung,代码行数:23,代码来源:CallableStatementRegressionTest.java

示例7: setSQLXML

import java.sql.CallableStatement; //导入依赖的package包/类
public void setSQLXML(String parameterName, SQLXML xmlObject) throws SQLException {
    try {
        if (this.wrappedStmt != null) {
            ((CallableStatement) this.wrappedStmt).setSQLXML(parameterName, xmlObject);
        } else {
            throw SQLError.createSQLException("No operations allowed after statement closed", SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
        }
    } catch (SQLException sqlEx) {
        checkAndFireConnectionError(sqlEx);
    }
}
 
开发者ID:rafallis,项目名称:BibliotecaPS,代码行数:12,代码来源:JDBC4CallableStatementWrapper.java

示例8: setClob

import java.sql.CallableStatement; //导入依赖的package包/类
public void setClob(String parameterName, Reader reader) throws SQLException {
    try {
        if (this.wrappedStmt != null) {
            ((CallableStatement) this.wrappedStmt).setClob(parameterName, reader);
        } else {
            throw SQLError.createSQLException("No operations allowed after statement closed", SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
        }
    } catch (SQLException sqlEx) {
        checkAndFireConnectionError(sqlEx);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:JDBC4CallableStatementWrapper.java

示例9: prepareCall

import java.sql.CallableStatement; //导入依赖的package包/类
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
{
	try
	{
		CallableStatement statement = realConnection.prepareCall(sql, resultSetType, resultSetConcurrency);
		return (CallableStatement) new CallableStatementSpy(sql, this, statement);
	}
	catch(SQLException s)
	{
		String methodCall = "prepareCall(" + sql + ", " + resultSetType + ", " + resultSetConcurrency + ")";
		reportException(methodCall, s, sql);
		throw s;
	}
}
 
开发者ID:skeychen,项目名称:dswork.jdbc,代码行数:15,代码来源:ConnectionSpy.java

示例10: setObject

import java.sql.CallableStatement; //导入依赖的package包/类
/**
 * Support for java.sql.JDBCType/java.sql.SQLType.
 * 
 * @param parameterIndex
 * @param x
 * @param targetSqlType
 * @param scaleOrLength
 * @throws SQLException
 */
public void setObject(int parameterIndex, Object x, SQLType targetSqlType, int scaleOrLength) throws SQLException {
    try {
        if (this.wrappedStmt != null) {
            ((CallableStatement) this.wrappedStmt).setObject(parameterIndex, x, targetSqlType, scaleOrLength);
        } else {
            throw SQLError.createSQLException("No operations allowed after statement closed", SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
        }
    } catch (SQLException sqlEx) {
        checkAndFireConnectionError(sqlEx);
    }
}
 
开发者ID:rafallis,项目名称:BibliotecaPS,代码行数:21,代码来源:JDBC42CallableStatementWrapper.java

示例11: getResult

import java.sql.CallableStatement; //导入依赖的package包/类
public Object getResult(CallableStatement cs, int columnIndex) throws SQLException {

            Object bigdec = cs.getBigDecimal(columnIndex);
            if (cs.wasNull()) {
                return null;
            }
            else {
                return bigdec;
            }
        }
 
开发者ID:uavorg,项目名称:uavstack,代码行数:11,代码来源:DAOFactory.java

示例12: getNString

import java.sql.CallableStatement; //导入依赖的package包/类
public String getNString(int parameterIndex) throws SQLException {
    try {
        if (this.wrappedStmt != null) {
            return ((CallableStatement) this.wrappedStmt).getNString(parameterIndex);
        } else {
            throw SQLError.createSQLException("No operations allowed after statement closed", SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
        }
    } catch (SQLException sqlEx) {
        checkAndFireConnectionError(sqlEx);
    }

    return null;
}
 
开发者ID:bragex,项目名称:the-vigilantes,代码行数:14,代码来源:JDBC4CallableStatementWrapper.java

示例13: getTime

import java.sql.CallableStatement; //导入依赖的package包/类
public Time getTime(int parameterIndex) throws SQLException {
    try {
        if (this.wrappedStmt != null) {
            return ((CallableStatement) this.wrappedStmt).getTime(parameterIndex);
        }
        throw SQLError.createSQLException("No operations allowed after statement closed", SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);

    } catch (SQLException sqlEx) {
        checkAndFireConnectionError(sqlEx);
    }

    return null;
}
 
开发者ID:Jugendhackt,项目名称:OpenVertretung,代码行数:14,代码来源:CallableStatementWrapper.java

示例14: prepareCall

import java.sql.CallableStatement; //导入依赖的package包/类
public CallableStatement prepareCall(String sql, int resultSetType,
        int resultSetConcurrency) throws SQLException {

    validate();

    return this.getConnection().prepareCall(sql, resultSetType,
            resultSetConcurrency);
}
 
开发者ID:s-store,项目名称:s-store,代码行数:9,代码来源:BaseConnectionWrapper.java

示例15: createCallableStatement

import java.sql.CallableStatement; //导入依赖的package包/类
private CallableStatement createCallableStatement(int numberOfParameters) throws Exception {
	CallableStatement cStmt = null;

	String callString = "{call " + procedure + "( ";
	for (int i = 0; i < numberOfParameters - 1; i++) {
		callString = callString + "?, ";
	}
	if (numberOfParameters > 0) {
		callString = callString + "? ";
	}
	callString = callString + " )}";
	cStmt = con.prepareCall(callString);

	return cStmt;
}
 
开发者ID:jaffa-projects,项目名称:jaffa-framework,代码行数:16,代码来源:JDBCLogger.java


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