项目:ProyectoPacientes
文件:CallableStatementRegressionTest.java
/**
* 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());
}
项目:s-store
文件:WrapperInvocationHandler.java
/**
* 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;
}
}
/**
* 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;
}
}
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) {
}
}
项目:the-vigilantes
文件:CallableStatementRegressionTest.java
/**
* Tests fix for BUG#22024 - Newli@R_502_6431@ 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();
}
}
}
项目:OpenVertretung
文件:CallableStatementRegressionTest.java
/**
* 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();
}
}
}
项目:OpenVertretung
文件:CallableStatementRegressionTest.java
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();
}
}
}
项目:BibliotecaPS
文件:JDBC4CallableStatementWrapper.java
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);
}
}
项目:lams
文件:JDBC4CallableStatementWrapper.java
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",this.exceptionInterceptor);
}
} catch (sqlException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
}
项目:dswork.jdbc
文件:ConnectionSpy.java
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;
}
}
项目:BibliotecaPS
文件:JDBC42CallableStatementWrapper.java
/**
* 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",this.exceptionInterceptor);
}
} catch (sqlException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
}
public Object getResult(CallableStatement cs,int columnIndex) throws sqlException {
Object bigdec = cs.getBigDecimal(columnIndex);
if (cs.wasNull()) {
return null;
}
else {
return bigdec;
}
}
项目:the-vigilantes
文件:JDBC4CallableStatementWrapper.java
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",this.exceptionInterceptor);
}
} catch (sqlException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
return null;
}
项目:OpenVertretung
文件:CallableStatementWrapper.java
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",this.exceptionInterceptor);
} catch (sqlException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
return null;
}
项目:s-store
文件:BaseConnectionWrapper.java
项目:jaffa-framework
文件:JDBCLogger.java
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;
}
项目:BibliotecaPS
文件:CallableStatementWrapper.java
public Timestamp getTimestamp(String parameterName,Calendar cal) throws sqlException {
try {
if (this.wrappedStmt != null) {
return ((CallableStatement) this.wrappedStmt).getTimestamp(parameterName,cal);
}
throw sqlError.createsqlException("No operations allowed after statement closed",this.exceptionInterceptor);
} catch (sqlException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
return null;
}
项目:BibliotecaPS
文件:CallableStatementWrapper.java
public void setobject(String parameterName,int targetsqlType,int scale) throws sqlException {
try {
if (this.wrappedStmt != null) {
((CallableStatement) this.wrappedStmt).setobject(parameterName,scale);
} else {
throw sqlError.createsqlException("No operations allowed after statement closed",this.exceptionInterceptor);
}
} catch (sqlException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
}
项目:ProyectoPacientes
文件:JDBC42CallableStatementWrapper.java
/**
* Support for java.sql.JDBCType/java.sql.sqlType.
*
* @param parameterIndex
* @param x
* @param targetsqlType
* @param scaleOrLength
* @throws sqlException
*/
public void setobject(int parameterIndex,this.exceptionInterceptor);
}
} catch (sqlException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
}
项目:the-vigilantes
文件:CallableStatementWrapper.java
public void setTime(String parameterName,Time x,Calendar cal) throws sqlException {
try {
if (this.wrappedStmt != null) {
((CallableStatement) this.wrappedStmt).setTime(parameterName,cal);
} else {
throw sqlError.createsqlException("No operations allowed after statement closed",this.exceptionInterceptor);
}
} catch (sqlException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
}
项目:the-vigilantes
文件:CallableStatementWrapper.java
public void setBytes(String parameterName,byte[] x) throws sqlException {
try {
if (this.wrappedStmt != null) {
((CallableStatement) this.wrappedStmt).setBytes(parameterName,x);
} else {
throw sqlError.createsqlException("No operations allowed after statement closed",this.exceptionInterceptor);
}
} catch (sqlException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
}
项目:OpenVertretung
文件:CallableStatementWrapper.java
项目:s-store
文件:TestJDBCDriver.java
项目:the-vigilantes
文件:JDBC4CallableStatementWrapper.java
/**
* @see java.sql.CallableStatement#getNCharacterStream(java.lang.String)
*/
public Reader getNCharacterStream(String parameterName) throws sqlException {
try {
if (this.wrappedStmt != null) {
return ((CallableStatement) this.wrappedStmt).getNCharacterStream(parameterName);
} else {
throw sqlError.createsqlException("No operations allowed after statement closed",this.exceptionInterceptor);
}
} catch (sqlException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
return null;
}
项目:OpenVertretung
文件:CallableStatementRegressionTest.java
/**
* Tests fix for BUG#28689 - CallableStatement.executeBatch() doesn't work
* when connection property "noAccesstoProcedureBodies" has been set to
* "true".
*
* The fix involves changing the behavior of "noAccesstoProcedureBodies",in
* that the driver will Now report all paramters as "IN" paramters but allow
* callers to call registerOutParameter() on them.
*
* @throws Exception
*/
public void testBug28689() throws Exception {
if (!versionMeetsMinimum(5,0)) {
return; // no stored procedures
}
createTable("testBug28689","(" +
"`id` int(11) NOT NULL auto_increment,`usuario` varchar(255) default NULL,PRIMARY KEY (`id`))");
this.stmt.executeUpdate("INSERT INTO testBug28689 (usuario) VALUES ('AAAAAA')");
createProcedure("sp_testBug28689","(tid INT)\nBEGIN\nUPDATE testBug28689 SET usuario = 'BBBBBB' WHERE id = tid;\nEND");
Connection noprocedureBodiesConn = getConnectionWithProps("noAccesstoProcedureBodies=true");
CallableStatement cStmt = null;
try {
cStmt = noprocedureBodiesConn.prepareCall("{CALL sp_testBug28689(?)}");
cStmt.setInt(1,1);
cStmt.addBatch();
cStmt.executeBatch();
assertEquals("BBBBBB",getSingleIndexedValueWithQuery(noprocedureBodiesConn,1,"SELECT `usuario` FROM testBug28689 WHERE id=1"));
} finally {
if (cStmt != null) {
cStmt.close();
}
if (noprocedureBodiesConn != null) {
noprocedureBodiesConn.close();
}
}
}
项目:BibliotecaPS
文件:StatementRegressionTest.java
/**
* Tests fix for Bug#71131 - Poor error message in CallableStatement.java.
*/
public void testBug71131() throws Exception {
createProcedure("testBug71131","(IN r DOUBLE,OUT p DOUBLE) BEGIN SET p = 2 * r * PI(); END");
final CallableStatement cstmt = this.conn.prepareCall("{ CALL testBug71131 (?,5) }");
assertThrows(sqlException.class,"Parameter p is not registered as an output parameter",new Callable<Void>() {
public Void call() throws Exception {
cstmt.execute();
return null;
}
});
cstmt.close();
}
项目:ProyectoPacientes
文件:CallableStatementWrapper.java
public float getFloat(int parameterIndex) throws sqlException {
try {
if (this.wrappedStmt != null) {
return ((CallableStatement) this.wrappedStmt).getFloat(parameterIndex);
}
throw sqlError.createsqlException("No operations allowed after statement closed",this.exceptionInterceptor);
} catch (sqlException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
return 0;
}
项目:ProyectoPacientes
文件:CallableStatementWrapper.java
public Timestamp getTimestamp(int parameterIndex,Calendar cal) throws sqlException {
try {
if (this.wrappedStmt != null) {
return ((CallableStatement) this.wrappedStmt).getTimestamp(parameterIndex,this.exceptionInterceptor);
} catch (sqlException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
return null;
}
项目:OpenVertretung
文件:CallableStatementWrapper.java
public void registerOutParameter(int paramIndex,int sqlType,String typeName) throws sqlException {
try {
if (this.wrappedStmt != null) {
((CallableStatement) this.wrappedStmt).registerOutParameter(paramIndex,sqlType,typeName);
} else {
throw sqlError.createsqlException("No operations allowed after statement closed",this.exceptionInterceptor);
}
} catch (sqlException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
}
项目:tangyuan2
文件:DateTypeHandler.java
项目:BibliotecaPS
文件:JDBC4CallableStatementWrapper.java
/**
* @see java.sql.CallableStatement#getCharacterStream(int)
*/
public Reader getCharacterStream(int parameterIndex) throws sqlException {
try {
if (this.wrappedStmt != null) {
return ((CallableStatement) this.wrappedStmt).getCharacterStream(parameterIndex);
} else {
throw sqlError.createsqlException("No operations allowed after statement closed",this.exceptionInterceptor);
}
} catch (sqlException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
return null;
}
public int getSuitesCount( String whereClause ) throws DatabaseAccessException {
Connection connection = getConnection();
String sqlLog = new sqlRequestFormatter().add("where",whereClause).format();
CallableStatement callableStatement = null;
ResultSet rs = null;
try {
callableStatement = connection.prepareCall("{ call sp_get_suites_count(?) }");
callableStatement.setString(1,whereClause);
rs = callableStatement.executeQuery();
int suitesCount = 0;
while (rs.next()) {
suitesCount = rs.getInt("suitesCount");
logQuerySuccess(sqlLog,"suites",suitesCount);
break;
}
return suitesCount;
} catch (Exception e) {
throw new DatabaseAccessException("Error when " + sqlLog,e);
} finally {
dbutils.closeResultSet(rs);
dbutils.close(connection,callableStatement);
}
}
项目:lams
文件:CallableStatementWrapper.java
public long getLong(String parameterName) throws sqlException {
try {
if (this.wrappedStmt != null) {
return ((CallableStatement) this.wrappedStmt).getLong(parameterName);
}
throw sqlError.createsqlException("No operations allowed after statement closed",this.exceptionInterceptor);
} catch (sqlException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
return 0;
}
项目:ProyectoPacientes
文件:JDBC4CallableStatementWrapper.java
项目:ProyectoPacientes
文件:CallableStatementWrapper.java
项目:the-vigilantes
文件:CallableStatementWrapper.java
public void setNull(String parameterName,int sqlType) throws sqlException {
try {
if (this.wrappedStmt != null) {
((CallableStatement) this.wrappedStmt).setNull(parameterName,sqlType);
} else {
throw sqlError.createsqlException("No operations allowed after statement closed",this.exceptionInterceptor);
}
} catch (sqlException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
}
项目:OpenVertretung
文件:JDBC42CallableStatementWrapper.java
/**
* Support for java.sql.JDBCType/java.sql.sqlType.
*
* @param parameterName
* @param sqlType
* @param scale
* @throws sqlException
*/
public void registerOutParameter(String parameterName,sqlType sqlType,int scale) throws sqlException {
try {
if (this.wrappedStmt != null) {
((CallableStatement) this.wrappedStmt).registerOutParameter(parameterName,String typeName) throws sqlException {
try {
if (this.wrappedStmt != null) {
((CallableStatement) this.wrappedStmt).setNull(parameterName,this.exceptionInterceptor);
}
} catch (sqlException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
}
项目:ProyectoPacientes
文件:CallableStatementWrapper.java
public int getInt(String parameterName) throws sqlException {
try {
if (this.wrappedStmt != null) {
return ((CallableStatement) this.wrappedStmt).getInt(parameterName);
}
throw sqlError.createsqlException("No operations allowed after statement closed",this.exceptionInterceptor);
} catch (sqlException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
return 0;
}
项目:the-vigilantes
文件:CallableStatementWrapper.java
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。