花无缺007
2017-04-15 06:36
采纳率: 50%
浏览 2.5k

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

本来是想通过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.

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题