- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE xml>
- <c3p0-config>
-     <named-config name="mysql">
-         <property name="user">test01</property>
-         <property name="password">test01</property>
-         <property name="driverClass">com.mysql.jdbc.Driver</property>
-         <property name="jdbcUrl">jdbc:mysql://10.49.40.127:3306/testdb?&useUnicode=true&characterEncoding=utf8&autoReconnect=true&failOverReadOnly=false&serverTimezone=Asia/Shanghai</property>
-         <property name="initialPoolSize">10</property>
-         <!--最大空闲时间,30秒内未使用则连接被丢弃。若为0则永不丢弃。默认值: 0 -->
-         <property name="maxIdleTime">30</property>
-         <property name="maxPoolSize">100</property>
-         <property name="minPoolSize">10</property>
-     </named-config>
- </c3p0-config>
 
上边这种配置方式 会报The reference to entity "useUnicode" must end with the ';' delimiter. 这个错误。
这是由xml文件中的编码规则决定要这么变换。在xml文件中有以下几类字符要进行转义替换:
| < | < | 小于号 | 
| > | > | 大于号 | 
| & | & | 和 | 
| ' | ' | 单引号 | 
| " | " | 双引号 | 
 
 
 
 
 
 
 
正确的方式
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE xml>
- <c3p0-config>
-     <named-config name="mysql">
-         <property name="user">test01</property>
-         <property name="password">test01</property>
-         <property name="driverClass">com.mysql.jdbc.Driver</property>
-         <property name="jdbcUrl">jdbc:mysql://10.49.40.127:3306/testdb?&useUnicode=true&characterEncoding=utf8&autoReconnect=true&failOverReadOnly=false&serverTimezone=Asia/Shanghai</property>
-         <property name="initialPoolSize">10</property>
-         <!--最大空闲时间,30秒内未使用则连接被丢弃。若为0则永不丢弃。默认值: 0 -->
-         <property name="maxIdleTime">30</property>
-         <property name="maxPoolSize">100</property>
-         <property name="minPoolSize">10</property>
-     </named-config>
- </c3p0-config>