c3p0 数据源连接mysql_关于数据库连接(c3p0连接mysql)出现的问题

在尝试通过jsp页面向MySQL数据库添加数据时,遇到500错误,异常信息显示QueryRunner需要DataSource或者直接传递Connection。问题出现在FoodTypeService和FoodTypeServlet中,可能是DataSource配置未正确应用。
摘要由CSDN通过智能技术生成

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

本来是想通过jsp页面添加一个数据,跳转到访问serlvlet页面通过jbutils连接mqsql保存数据,但是我检查了c3p0的配置文件和datasource对象,queryrunner对象都可以正常新建,具体问题找不到,谢谢大家了这是访问页面的报错代码

HTTP Status 500 - java.lang.RuntimeException: java.sql.SQLException: QueryRunner requires a DataSource to be invoked in this way, or a Connection should be passed in

type Exception report

message java.lang.RuntimeException: java.sql.SQLException: QueryRunner requires a DataSource to be invoked in this way, or a Connection should be passed in

description The server encountered an internal error that prevented it from fulfilling this request.

exception

java.lang.RuntimeException: java.lang.RuntimeException: java.sql.SQLException: QueryRunner requires a DataSource to be invoked in this way, or a Connection should be passed in

serviceimp.FoodTypeService.save(FoodTypeService.java:62)

servlet.FoodTypeServlet.addFoodType(FoodTypeServlet.java:65)

servlet.FoodTypeServlet.doGet(FoodTypeServlet.java:44)

servlet.FoodTypeServlet.doPost(FoodTypeServlet.java:105)

javax.servlet.http.HttpServlet.service(HttpServlet.java:643)

javax.servlet.http.HttpServlet.service(HttpServlet.java:723)

root cause

java.lang.RuntimeException: java.sql.SQLException: QueryRunner requires a DataSource to be invoked in this way, or a Connection should be passed in

daoimp.FoodTypeDao.save(FoodTypeDao.java:36)

serviceimp.FoodTypeService.save(FoodTypeService.java:59)

servlet.FoodTypeServlet.addFoodType(FoodTypeServlet.java:65)

servlet.FoodTypeServlet.doGet(FoodTypeServlet.java:44)

servlet.FoodTypeServlet.doPost(FoodTypeServlet.java:105)

javax.servlet.http.HttpServlet.service(HttpServlet.java:643)

javax.servlet.http.HttpServlet.service(HttpServlet.java:723)

root cause

java.sql.SQLException: QueryRunner requires a DataSource to be invoked in this way, or a Connection should be passed in

org.apache.commons.dbutils.AbstractQueryRunner.prepareConnection(AbstractQueryRunner.java:200)

org.apache.commons.dbutils.QueryRunner.update(QueryRunner.java:437)

daoimp.FoodTypeDao.save(FoodTypeDao.java:34)

serviceimp.FoodTypeService.save(FoodTypeService.java:59)

servlet.FoodTypeServlet.addFoodType(FoodTypeServlet.java:65)

servlet.FoodTypeServlet.doGet(FoodTypeServlet.java:44)

servlet.FoodTypeServlet.doPost(FoodTypeServlet.java:105)

javax.servlet.http.HttpServlet.service(HttpServlet.java:643)

javax.servlet.http.HttpServlet.service(HttpServlet.java:723)

note The full stack trace of the root cause is available in the Apache Tomcat/6.0.39 logs.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值