jsp使用mysql數據庫連接池的方法
1.在conf目錄中打開context.xml文件,并在文件寫如下代碼;
name = "jdbc/ConnectionPool" auth = "Container"
type = "javax.sql.DataSource"
password = "123456"
driverClassName = "com.mysql.jdbc.Driver"
maxIdle = "2"
maxWait = "5000"
username = "root"
url = "jdbc:mysql://localhost:3306/study?characterEncoding=GBK"
maxActive = "4"/>
Web-INF/web.xml
2.然后打開web.xml文件,在文件寫入代碼;
GuestBook
jdbc/ConnectionPool
javax.sql.DataSource
Container