最近新项目使用tomcat中配置jndi连接mysql的方式,在使用过程中发现查询条件为中文的时候查询不出结果,经过一通折腾,发现是jndi在连接数据库的时候忘记设置字符编码。

修改之后的完整配置如下:

<Resource auth="Container" driverClassName="com.mysql.jdbc.Driver" maxActive="10" maxIdle="4" maxWait="10000" name="jdbc/test" password="test" type="javax.sql.DataSource" url="jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&amp;characterEncoding=utf8" username="test"/>

 

注意url项中使用的是&amp;

相关文章:

  • 2022-12-23
  • 2022-02-07
  • 2022-02-08
  • 2022-12-23
  • 2022-01-04
  • 2022-01-04
猜你喜欢
  • 2021-12-24
  • 2021-08-03
  • 2022-01-26
  • 2022-02-18
  • 2021-07-31
  • 2021-06-20
相关资源
相似解决方案