The reference to entity "characterEncoding" must end with the ';' delimiter.

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
RDS MySQL Serverless 高可用系列,价值2615元额度,1个月
简介:

  在实现Java数据池时,进行配置数据源时出现了该报错信息。报错信息出现在 context.xml 中,原语句是:

<Context>    

   <Resource name="jdbc/onlinefriend"

    auth="Container" 

    type="javax.sql.DataSource"         

     driverClassName="com.mysql.jdbc.Driver"    

     url="jdbc:mysql://127.0.0.1:3306/onlinefriend?useUnicode=true&characterEncoding=utf-8"

     username="root"  

     password="root" 

     maxActive="100"  

     maxIdle="30"  

     maxWait="10000"    />    

 </Context>  


这是由于xml的编码问题导致,小小的修改后问题解决:

<Context>    

   <Resource name="jdbc/onlinefriend"

    auth="Container" 

    type="javax.sql.DataSource"         

     driverClassName="com.mysql.jdbc.Driver"    

     url="jdbc:mysql://127.0.0.1:3306/onlinefriend?useUnicode=true&amp;characterEncoding=utf-8"

     username="root"  

     password="root" 

     maxActive="100"  

     maxIdle="30"  

     maxWait="10000"    />    

 </Context>  


附:在xml文件中有以下几类字符要进行转义替换:

&lt; < 小于
&gt; > 大于
&amp; &
&apos; ' 单引号
&quot; " 双引号


本文转自 pangfc 51CTO博客,原文链接:http://blog.51cto.com/983836259/1697596,如需转载请自行联系原作者

相关实践学习
如何快速连接云数据库RDS MySQL
本场景介绍如何通过阿里云数据管理服务DMS快速连接云数据库RDS MySQL,然后进行数据表的CRUD操作。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
打赏
0
0
0
0
265
分享
相关文章
SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘thinkphp.test‘ don‘t exsit
SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘thinkphp.test‘ don‘t exsit
470 0
Data truncation: Incorrect date value: ‘2022-11-28T16:00:00.000Z‘ for column ‘start_date‘ at row 1
Data truncation: Incorrect date value: ‘2022-11-28T16:00:00.000Z‘ for column ‘start_date‘ at row 1
310 0
Incorrect table definition; there can be only one auto column and it must be defined as a key
Incorrect table definition; there can be only one auto column and it must be defined as a key
252 0
Incorrect table definition; there can be only one auto column and it must be defined as a key
TestRange.cs error CS0104: `Range' is an ambiguous reference between `System.Range' and Gtk.Range
TestRange.cs error CS0104: `Range' is an ambiguous reference between `System.Range' and Gtk.Range
196 0
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (ch
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (ch
报错:Incorrect datetime value: '0000-00-00 00:00:00' for column 'login_time' at row 1
报错:Incorrect datetime value: '0000-00-00 00:00:00' for column 'login_time' at row 1
727 0
Open quote is expected for attribute "{1}" associated with an element type "id".
Open quote is expected for attribute "{1}" associated with an element type "id".
225 0
Open quote is expected for attribute "{1}" associated with an element type "id".
JPA异常:Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
JPA异常:Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
2242 0
错误Batch update returned unexpected row count from update [0]; actual row count: 0;
错误Batch update returned unexpected row count from update [0]; actual row count: 0;   把开发过程中碰到的BUG累积下来也是一笔财富。
3786 0
错误Batch update returned unexpected row count from update [0]; actual row count: 0;