Jndi方法连接数据库,tomcat下context.xml配置
<Resource auth="Container" driverClassName="com.mysql.jdbc.Driver" maxActive="5" maxIdle="2" maxWait="10000" name="jdbc/webframe" password="root" type="javax.sql.DataSource" url="jdbc:mysql://127.0.0.1:3306/xxx?useUnicode=true&characterEncoding=utf8" username="root"/>
主要是?后面的useUnicode=true&characterEncoding=utf8添加即可,其中‘&’是‘&’转义