我的服务器使用hibernate 3.6和c3p0-0.9.5.2与mysql数据库。 我尝试使用mysql jdbc驱动程序的这个特殊功能
com.mysql.jdbc.Statement.setLocalInfileInputStream(InputStream is)
所以作为c3p0文档,我需要使用com.mchange.v2.c3p0.impl.NewProxyStatement的rawStatementOperation()函数:
InputStream is = new ByteArrayInputStream("myString".getBytes());
Method m = com.mysql.jdbc.Statement.class.getMethod("setLocalInfileInputStream", new Class[]{InputStream.class});
NewProxyStatement proxyStatement = (NewProxyStatement) connection.createStatement();
proxyStatement.rawStatementOperation(m, NewProxyStatement.RAW_STATEMENT, new Object[]{is});
它有错误:
Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at com.mchange.v2.c3p0.impl.NewProxyStatement.rawStatementOperation(NewProxyStatement.java:1077)
就好像它不能将ByteArrayInputStream识别为InputStream的子类
我也尝试使用ByteArrayInputStream.class而不是InputStream.class创建Method,但它找不到函数
NoSuchMethodException: com.mysql.jdbc.Statement.setLocalInfileInputStream(java.io.ByteArrayInputStream中)
我做错了吗? 非常感谢