由于是新手的问题,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输错了,好在发现了。

最新文章

  1. SQL SERVER 临时表导致存储过程重编译(recompile)的一些探讨
  2. nginx 配置php
  3. 如何完全卸载(Mac&amp;Windows)office 365 ProPlus
  4. Evacuation Plan-POJ2175最小费用消圈算法
  5. 用户代理字符串userAgent可实现的四个识别
  6. Lua与C的交互
  7. myEclipse 界面窗口打不开问题
  8. -Dmaven.multiModuleProjectDirectory system property is not set. Check $M2_HOME environment variable
  9. HTTP message vs SOAP message
  10. Numpy中的矩阵计算
  11. Codevs No.1245 最小的N个和
  12. Python中for\while的用法
  13. NFC应用(一)卡应用
  14. How to find variable is empty in shell script
  15. 【IE6的疯狂之十二】一个display:none引起的3像素的BUG
  16. UIWebView 使用要注意的几点
  17. JMeter 监控和记录&amp;常用功能
  18. 014_IP专项研究监控
  19. flex 左边固定宽度,右边自适应
  20. I: Carryon的字符串排序(字典树/map映射)

热门文章

  1. Codeforces Round #305 (Div. 1) B. Mike and Feet
  2. Codeforces Round #670 (Div. 2) C. Link Cut Centroids (dfs,树)
  3. PAT L2-005. 集合相似度 【stl set】
  4. 51nod 1073约瑟夫环 递归公式法
  5. 康托展开:对全排列的HASH和还原,判断搜索中的某个排列是否出现过
  6. Linux 驱动框架---input子系统框架
  7. python 爬取腾讯视频的全部评论
  8. css background transparent All In One
  9. Apple iOS 触控按钮 自动关闭 bug
  10. Nginx环境下,PHP下载,中文文件,下载失效(英文可以下载)怎么解决呢?