用QueryRunner 实现插入的sql语句,为何出现了错误

TimeFR 2016-06-21 02:53:46
/**
* 测试QueryRunner 类的update方法 该方法可用于INSERT,UPDATE 和 DELETE
*/
@Test
public void testQueryRunnerUpdate() {
// 1.创建QueryRunner 的实现类
QueryRunner queryRunner = new QueryRunner();

String sql = "insert into customer values(2,'bb','2-7月-1965')";

Connection connection = null;
try {
connection = JDBCTools.getConnection();//连接的是oracle数据库,可以获取链接数据库地址,没有问题

// 2.使用其update方法
queryRunner.update(connection, sql, 1);

} catch (Exception e) {
e.printStackTrace();
} finally {
JDBCTools.release(null, null, connection);//关闭流的操作,没有问题
}

}

}

不知道为了抛了异常。用的是commons-dbutils-1.3.jar工具包,就是插入不了。希望大家帮我解答,谢谢大家。


异常信息如下
java.lang.AbstractMethodError: oracle.jdbc.driver.T4CPreparedStatement.getParameterMetaData()Ljava/sql/ParameterMetaData;
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.getParameterMetaData(NewProxyPreparedStatement.java:573)
at org.apache.commons.dbutils.QueryRunner.fillStatement(QueryRunner.java:176)
at org.apache.commons.dbutils.QueryRunner.update(QueryRunner.java:595)
at org.apache.commons.dbutils.QueryRunner.update(QueryRunner.java:575)
at com.time.weo.DBUtilsTest.testQueryRunnerUpdate(DBUtilsTest.java:100)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

...全文
477 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧