写JavaWeb小项目的时候,需要配置c3p0-config.xml,eclipse上总是有个×,配置文件如下:
<c3p0-config>
<default-config>
<property name="driverClass">com.mysql.cj.jdbc.Driver</property>
<property name="jdbcUrl">jdbc:mysql://localhost/stus?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT</property>
<property name="user">root</property>
<property name="password">root</property>
<property name="initialPoolSize">10</property>
<property name="maxIdleTime">30</property>
<property name="maxPoolSize">100</property>
<property name="minPoolSize">10</property>
<property name="maxStatements">200</property>
</default-config>
</c3p0-config>
很是让人抓狂!!!
通过使用xml格式化在线工具,报错:
Error on line 4 of document : The reference to entity "characterEncoding" must end with the ';' delimiter. Nested exception: The reference to entity "characterEncoding" must end with the ';' delimiter.
百度一下,发现问题如下:
这个错误是转义字符的问题
在.xml文件中有五种字符必须转义才能使用
1. > == > 大于号
2. < == < 小于号
3. & == & 和
4. ' == ' 单引号
5. " == " 双引号
我出现这个错误就是由于配置文件中的连接驱动是:
jdbc:mysql://localhost/stus?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT
中间有个两个&, 故报错
转义成 &
即可解决