本文整理匯總了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());
}
示例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;
}
}
示例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) {
}
}
示例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();
}
}
}
示例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();
}
}
}
示例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();
}
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
}
示例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);
}
}
示例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;
}
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}