Search in sources :

Example 1 with CallableStatementProxyImpl

use of com.alibaba.druid.proxy.jdbc.CallableStatementProxyImpl in project druid by alibaba.

the class CallableStatementProxyImplTest method test_call.

public void test_call() throws Exception {
    DataSourceProxyConfig config = new DataSourceProxyConfig();
    DataSourceProxy dataSource = new DataSourceProxyImpl(null, config);
    FilterEventAdapter filter = new FilterEventAdapter() {
    };
    filter.init(dataSource);
    config.getFilters().add(filter);
    String sql = "CALL P_0(?, ?)";
    CallableStatementProxyImpl rawCallStatement = new FakeCallableStatement(new ConnectionProxyImpl(null, null, null, 0), null, sql, 1001);
    ConnectionProxy connection = new ConnectionProxyImpl(dataSource, null, new Properties(), 1001);
    CallableStatementProxyImpl cstmt = new CallableStatementProxyImpl(connection, rawCallStatement, sql, 2001);
    cstmt.registerOutParameter(1, Types.VARCHAR);
    cstmt.registerOutParameter(1, Types.VARCHAR, "VARCHAR");
    cstmt.registerOutParameter(1, Types.VARCHAR, 3);
    cstmt.registerOutParameter("1", Types.VARCHAR);
    cstmt.registerOutParameter("1", Types.VARCHAR, "VARCHAR");
    cstmt.registerOutParameter("1", Types.VARCHAR, 3);
    cstmt.setBoolean("1", true);
    cstmt.setByte("1", (byte) 0);
    cstmt.setShort("1", (short) 0);
    cstmt.setInt("1", 0);
    cstmt.setLong("1", 0);
    cstmt.setFloat("1", 0);
    cstmt.setDouble("1", 0);
    cstmt.setBigDecimal("1", new BigDecimal("111"));
    cstmt.setString("1", "X");
    cstmt.setURL("1", null);
    cstmt.setSQLXML("1", null);
    cstmt.setBytes("1", null);
    cstmt.setDate("1", null);
    cstmt.setDate("1", null, Calendar.getInstance());
    cstmt.setTime("1", null);
    cstmt.setTime("1", null, Calendar.getInstance());
    cstmt.setTimestamp("1", null);
    cstmt.setTimestamp("1", null, Calendar.getInstance());
    cstmt.setAsciiStream("1", null);
    cstmt.setAsciiStream("1", null, 0);
    cstmt.setAsciiStream("1", null, 0L);
    cstmt.setBinaryStream("1", null);
    cstmt.setBinaryStream("1", null, 0);
    cstmt.setBinaryStream("1", null, 0L);
    cstmt.setObject("1", null);
    cstmt.setObject("1", null, Types.VARCHAR);
    cstmt.setObject("1", null, Types.VARCHAR, 3);
    cstmt.setCharacterStream("1", null);
    cstmt.setCharacterStream("1", null, 0);
    cstmt.setCharacterStream("1", null, 0L);
    cstmt.setNull("1", Types.VARCHAR);
    cstmt.setNull("1", Types.VARCHAR, "VARCHAR");
    cstmt.setRowId("1", null);
    cstmt.setNString("1", null);
    cstmt.setNCharacterStream("1", null);
    cstmt.setNCharacterStream("1", null, 0);
    cstmt.setNClob("1", (NClob) null);
    cstmt.setNClob("1", (Reader) null);
    cstmt.setNClob("1", (Reader) null, 0);
    cstmt.setClob("1", (Clob) null);
    cstmt.setClob("1", (Reader) null);
    cstmt.setClob("1", (Reader) null, 0);
    cstmt.setBlob("1", (Blob) null);
    cstmt.setBlob("1", (InputStream) null);
    cstmt.setBlob("1", (InputStream) null, 0);
    cstmt.setURL(1, null);
    cstmt.setSQLXML(1, null);
    cstmt.setArray(1, null);
    cstmt.setNCharacterStream(1, null);
    cstmt.setNCharacterStream(1, null, 0);
    cstmt.setNClob(1, (NClob) null);
    cstmt.setNClob(1, (Reader) null);
    cstmt.setNClob(1, (Reader) null, 0);
    cstmt.setNString(1, null);
    cstmt.setObject(1, null);
    cstmt.setRef(1, null);
    cstmt.setRowId(1, null);
    cstmt.setUnicodeStream(1, null, 0);
    cstmt.getClob(1);
    cstmt.getClob("1");
    cstmt.cancel();
    cstmt.getResultSet();
}
Also used : DataSourceProxyConfig(com.alibaba.druid.proxy.jdbc.DataSourceProxyConfig) DataSourceProxy(com.alibaba.druid.proxy.jdbc.DataSourceProxy) DataSourceProxyImpl(com.alibaba.druid.proxy.jdbc.DataSourceProxyImpl) FilterEventAdapter(com.alibaba.druid.filter.FilterEventAdapter) ConnectionProxyImpl(com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl) CallableStatementProxyImpl(com.alibaba.druid.proxy.jdbc.CallableStatementProxyImpl) Properties(java.util.Properties) ConnectionProxy(com.alibaba.druid.proxy.jdbc.ConnectionProxy) BigDecimal(java.math.BigDecimal)

Example 2 with CallableStatementProxyImpl

use of com.alibaba.druid.proxy.jdbc.CallableStatementProxyImpl in project druid by alibaba.

the class FilterChainTest_Clob_2 method setUp.

protected void setUp() throws Exception {
    dataSource = new DruidDataSource();
    MockCallableStatement mockStmt = new MockCallableStatement(null, "") {

        @Override
        public Object getObject(int parameterIndex) throws SQLException {
            invokeCount++;
            return new MockClob();
        }
    };
    statement = new CallableStatementProxyImpl(new ConnectionProxyImpl(null, null, null, 0), mockStmt, "", 1);
}
Also used : MockCallableStatement(com.alibaba.druid.mock.MockCallableStatement) MockClob(com.alibaba.druid.mock.MockClob) ConnectionProxyImpl(com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl) CallableStatementProxyImpl(com.alibaba.druid.proxy.jdbc.CallableStatementProxyImpl) DruidDataSource(com.alibaba.druid.pool.DruidDataSource)

Example 3 with CallableStatementProxyImpl

use of com.alibaba.druid.proxy.jdbc.CallableStatementProxyImpl in project druid by alibaba.

the class FilterChainTest_ResultSet_2 method setUp.

protected void setUp() throws Exception {
    dataSource = new DruidDataSource();
    ConnectionProxyImpl conn = new ConnectionProxyImpl(dataSource, null, new Properties(), 0);
    MockCallableStatement mockStmt = new MockCallableStatement(null, "") {

        @Override
        public Object getObject(int parameterIndex) throws SQLException {
            invokeCount++;
            return new MockResultSet(null);
        }
    };
    statement = new CallableStatementProxyImpl(conn, mockStmt, "", 1);
}
Also used : MockCallableStatement(com.alibaba.druid.mock.MockCallableStatement) ConnectionProxyImpl(com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl) MockResultSet(com.alibaba.druid.mock.MockResultSet) CallableStatementProxyImpl(com.alibaba.druid.proxy.jdbc.CallableStatementProxyImpl) Properties(java.util.Properties) DruidDataSource(com.alibaba.druid.pool.DruidDataSource)

Example 4 with CallableStatementProxyImpl

use of com.alibaba.druid.proxy.jdbc.CallableStatementProxyImpl in project druid by alibaba.

the class FilterChainTest_NClob_2 method setUp.

protected void setUp() throws Exception {
    dataSource = new DruidDataSource();
    MockCallableStatement mockStmt = new MockCallableStatement(null, "") {

        @Override
        public Object getObject(int parameterIndex) throws SQLException {
            invokeCount++;
            return new MockNClob();
        }
    };
    statement = new CallableStatementProxyImpl(new ConnectionProxyImpl(null, null, null, 0), mockStmt, "", 1);
}
Also used : MockCallableStatement(com.alibaba.druid.mock.MockCallableStatement) MockNClob(com.alibaba.druid.mock.MockNClob) ConnectionProxyImpl(com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl) CallableStatementProxyImpl(com.alibaba.druid.proxy.jdbc.CallableStatementProxyImpl) DruidDataSource(com.alibaba.druid.pool.DruidDataSource)

Aggregations

CallableStatementProxyImpl (com.alibaba.druid.proxy.jdbc.CallableStatementProxyImpl)4 ConnectionProxyImpl (com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl)4 MockCallableStatement (com.alibaba.druid.mock.MockCallableStatement)3 DruidDataSource (com.alibaba.druid.pool.DruidDataSource)3 Properties (java.util.Properties)2 FilterEventAdapter (com.alibaba.druid.filter.FilterEventAdapter)1 MockClob (com.alibaba.druid.mock.MockClob)1 MockNClob (com.alibaba.druid.mock.MockNClob)1 MockResultSet (com.alibaba.druid.mock.MockResultSet)1 ConnectionProxy (com.alibaba.druid.proxy.jdbc.ConnectionProxy)1 DataSourceProxy (com.alibaba.druid.proxy.jdbc.DataSourceProxy)1 DataSourceProxyConfig (com.alibaba.druid.proxy.jdbc.DataSourceProxyConfig)1 DataSourceProxyImpl (com.alibaba.druid.proxy.jdbc.DataSourceProxyImpl)1 BigDecimal (java.math.BigDecimal)1