JAVA连接MySQL,在URL指定字符集

来源:互联网 发布:mac腾讯视频播放不了 编辑:程序博客网 时间:2024/06/13 08:28

在xml里面

<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/act_test3?useUnicode=true&amp;characterEncoding=UTF-8" />


java代码里面

String url = "jdbc:mysql://localhost:3306/act_test3?useUnicode=true&characterEncoding=UTF-8";

这大概是由xml文件中的编码规则决定要这么变换。

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



&lt;


<


小于号


&gt;


>


大于号


&amp;


&



&apos;


'


单引号


&quot;


"


双引号


1 0
原创粉丝点击