在tomcat context的<context></context>里面加入
<Resource name="jdbc/db_blog" auth="Container" type="javax.sql.DataSource" maxActive="100" maxIdle="30" maxWait="10000" username="root" password="123456" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/db_blog"/>