数据库连接报错,求教!Connections could not be acquired from the underlying database!

项目运行后报错,求教

ERROR [com.jfinal.core.Config] - Plugin start error: com.jfinal.plugin.activerecord.ActiveRecordPlugin.

java.sql.SQLException : Connections could not be acquired from the underlying database!


properties文件:

devMode=true

debugMode=true

jdbc.driverClassName = com.mysql.jdbc.Driver

jdbc.url=jdbc:mysql://127.0.0.1:3306/sanyuan?useUnicode=true&characterEncoding=utf8

jdbc用户/密码/数据库均设置无问题

mysql-connector-java-5.1.6-bin.jar已经引入


start文件

package com;

import com.jfinal.core.JFinal;

public class WebAppStart {

public static String webRoot = "/";

public static void main(String[] args){

int port = 80;

if(args.length>0){

try{

port = Integer.parseInt(args[0]);

}catch(Exception e){

e.printStackTrace();

}

}

JFinal.start("WebRoot", port, webRoot, 5);

}

}


配置文件

public void configPlugin(Plugins me){

//shiro插件

me.add(new ShiroPlugin(this.routes));

// 配置mysql数据源

C3p0Plugin mysqlPool = new C3p0Plugin(

getProperty("jdbc.url"), 

getProperty("jdbc.username"), 

getProperty("jdbc.password").trim(),

getProperty("jdbc.driverClassName"));

me.add(mysqlPool);

ActiveRecordPlugin arp = new ActiveRecordPlugin(mysqlPool);

if(getPropertyToBoolean("devMode", false))arp.setShowSql(true);

me.add(arp);

// 这里增加数据表映射

TableMapping(arp);

}


评论区

JFinal

2016-07-27 10:09

换 DruidPlugin,c3p0 太老了

Zero-Lee

2016-07-27 10:10

@JFinal 好的,我试试

热门反馈

扫码入社