由于是新手的问题,C3P0的使用时严格跟着视频来的,但是问题却来的很突然

在导入了三个包以及创建了路径以后

进行测试

class JdbcutilsTest {

    @Test
void TestGetConnection() {
Connection conn = Jdbcutils.getConnection();
System.out.println(conn);
} }

第一个问题:named-config with name 'BarryLee' does not exist也就是找不到名字为BarryLee的confiig

以下是我的c3p0-config.xml的配置代码(最后修改完毕的)

<?xml version="1.0" encoding="UTF-8"?>
<c3p0-config>
<!-- 默认配置,如果没有指定则使用这个配置 -->
<default-config>
<property name="driverClass">com.mysql.cj.jdbc.Driver</property>
<property name="jdbcUrl">
<![CDATA[jdbc:mysql://localhost:3306/mvcproject?useUnicode=true&characterEncoding=utf8&use=true&useSSL=false&serverTimezone=GMT]]>
</property>
<property name="user">root</property>
<property name="password">XXXXXXX</property>
<!-- 初始化池大小 -->
<property name="initialPoolSize">2</property>
<!-- 最大空闲时间 -->
<property name="maxIdleTime">30</property>
<!-- 最多有多少个连接 -->
<property name="maxPoolSize">10</property>
<!-- 最少几个连接 -->
<property name="minPoolSize">2</property>
<!-- 每次最多可以执行多少个批处理语句 -->
<property name="maxStatements">50</property>
</default-config>
<!-- 命名的配置 -->
<named-config name="BarryLee">
<property name="driverClass">com.mysql.cj.jdbc.Driver</property>
<property name="jdbcUrl"><![CDATA[jdbc:mysql://localhost:3306/mvcproject?useUnicode=true&characterEncoding=utf8&use=true&useSSL=false&serverTimezone=GMT]]></property>
<property name="user">root</property>
<property name="password">XXXXXX</property>
<property name="acquireIncrement">5</property><!-- 如果池中数据连接不够时一次增长多少个 -->
<property name="initialPoolSize">100</property>
<property name="minPoolSize">50</property>
<property name="maxPoolSize">1000</property>
<property name="maxStatements">0</property>
<property name="maxStatementsPerConnection">5</property> <!-- he's important, but there's only one of him -->
</named-config>
</c3p0-config>

百度了看了一下前辈们的说法,懂了,是因为我把Xml文件放在lib文件夹下面了,xml文件必须要放在src文件夹下面才会起作用

而在我把这个xml文件放在src文件夹下之后,第二个问题出现了:Establishing SSL connection without server's identity verification is not recommende

具体给我的警告:

Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.

翻译之后:根据MySQL5.5.45+、5.6.26+和5.7.6+的要求,如果不设置显式选项,则默认必须建立SSL连接。为了符合不使用SSL的现有应用程序,verifyServerCertificate属性设置为“false”。您需要通过设置useSSL=false显式禁用SSL,或者设置useSSL=true并提供用于服务器证书验证的信任库。

发现是在jdbcUrl里面缺了东西,必须要禁用SSL,也就是useSSL=false;

接下来继续运行便有了第三个错误:com.mchange.v2.resourcepool.CannotAcquireResourceException:A ResourcePool could not acquire a resource from its primary factory or source.

 资源池无法从其主工厂或源获取资源。
继续百度,发现diverClass需要改成

com.mysql.cj.jdbc.Driver
和之前的相比
com.mysql.jdbc.Driver

还有就是我password输错了,好在发现了。

关于使用C3P0程序报错Having failed to acquire a resource, com.mchange.v2.resourcepool的问题的更多相关文章

  1. eclipse cdt运行c程序报错“launch failed,binary not found”

    1. 安装了eclipsecdt版 2. 采用mingw 编译第一个c程序,报错“launch failed,binary not found”.检查是mingw下的bin目录在环境变量里设置错了. ...

  2. 发送邮件程序报错454 Authentication failed以及POP3和SMTP简介

    一.发现问题 在测试邮件发送程序的时候,发送给自己的QQ邮箱,程序报错454 Authentication failed, please open smtp flag first. 二.解决问题 进入 ...

  3. eclipse运行hadoop程序报错:Connection refused: no further information

    eclipse运行hadoop程序报错:Connection refused: no further information log4j:WARN No appenders could be foun ...

  4. debug运行java程序报错

    debug运行java程序报错 ERROR: transport error 202: connect failed: Connection timed out ERROR: JDWP Transpo ...

  5. 执行opatch apply 报错 OPatch failed with error code 73

    .执行opatch apply 报错 OPatch failed [oracle@ora_11g 14275605]$ /opt/oracle/product/db_1/OPatch/opatch a ...

  6. eclipse下执行maprdeuc程序报错 java.lang.ClassNotFoundException

    最近遇到一个问题,不知怎么突然运行hadoop的map程序报错,困扰了我很久,现在来给大家分享分享.. 错误信息 2017-05-18 21:34:22,104 INFO [main] client. ...

  7. svn报错cleanup failed–previous operation has not finished; run cleanup if it was interrupted的解决办法

    今天在svn提交的时候它卡顿了一下,我以为已经提交完了,就按了一下,结果就再也恢复不了,也继续不了了... 报错 cleanup failed–previous operation has not f ...

  8. 运行编译后的程序报错 error while loading shared libraries: lib*.so: cannot open shared object file: No such file or directory

    运行编译后的程序报错  error while loading shared libraries: lib*.so: cannot open shared object file: No such f ...

  9. Window7中Eclipse运行MapReduce程序报错的问题

    按照文档:http://www.micmiu.com/bigdata/hadoop/hadoop2x-eclipse-mapreduce-demo/安装配置好Eclipse后,运行WordCount程 ...

随机推荐

  1. CF 1326 D. Prefix-Suffix Palindrome

    D. Prefix-Suffix Palindrome 题意 给一个字符串 s,求一个字符串 t,t 由 s 的某个前缀以及某个后缀拼接而成,且 t 是回文串,长度不能超过 s.输出最长的 t 分析 ...

  2. 【poj 1284】Primitive Roots(数论--欧拉函数 求原根个数){费马小定理、欧拉定理}

    题意:求奇质数 P 的原根个数.若 x 是 P 的原根,那么 x^k (k=1~p-1) 模 P 为1~p-1,且互不相同. (3≤ P<65536) 解法:有费马小定理:若 p 是质数,x^( ...

  3. Best Reward && Girls' research

    After an uphill battle, General Li won a great victory. Now the head of state decide to reward him w ...

  4. HDU 3488-Tour KM

    为什么可以这样拆点在 这道题 都已经证明过 代码: 1 //题目上面说了"The only exception is that the first and the last city sho ...

  5. Open3d之交互式可视化

    本篇教程介绍了Open3D的可视化窗口的交互功能. # -*- coding:utf-8 -*- import copy import numpy as np import open3d as o3d ...

  6. Filebeat 日志收集

    Filebeat 介绍 Filebeat 安装 # 上传代码包 [root@redis03 ~]# rz filebeat-6.6.0-x86_64.rpm # 安装 [root@redis03 ~] ...

  7. Shell 编程练习

    将后缀名为 .txt 的文件改成 .log [root@k8s-master test]# touch localhost_2020-01-{02..26}.txt [root@k8s-master ...

  8. 关于vmwaretools

    今天安装Ubuntu16.04-i386,vmware15.5,使用的快速安装,然后安装vmwaretools出现问题:无法复制粘贴,顶部管理"重新安装vmware-tools"选 ...

  9. 渗透技巧——如何逃逸Linux的受限制shell执行任意命令

    导语:本文介绍了如何在受限制的shell中执行任意命令,实现交互.其相应的利用场景是说当我们通过一些手段拿到当前Linux机器的shell时,由于当前shell的限制,很多命令不能执行,导致后续的渗透 ...

  10. 概率分析方法与推断统计(来自我写的python书)

    在数据分析统计的场景里,常用的方法除了描述性统计方法外,还有推断统计方法,如果再从工作性质上来划分,推断统计包含了参数估计和假设验证这两方面的内容.而推断统计用到了很多概率统计方法,所以本小节在介绍推 ...