Finally, there were many related information early, and there was no success; maybe it's not enough, maybe it is not enough.
Later, the official explanation of Tomcat was passed smoothly. Lessons: Take more official documents.
Although it is simple, it is still written out of the process:
1. MySQL Configuration
Ensure That You Follow these Instructions as variations can Cause Problems.
Create a New Test User, A New Database and A Single Test Table. Your MySQL User Must Have a Password Assigned. The Driver Will Fail If You Try To Connect with an an an an an an an escher password.
MySQL> grant all privileges on *. * to javauser @ localhost
-> Identified by 'javadude' with grant option;
Mysql> Create Database Javates
Mysql> Use javatest;
Mysql> Create Table TestData
-> ID INT NOT NULL AUTO_INCREMENT Primary Key,
-> foo varchar (25),
-> bar int);
NOTE: The Above User Should Be Removed Once Testing IS Complete!
Next INSERT Some Test Data Into The TestData Table.
Mysql> Insert Into TestData Values (Null, 'Hello', 12345);
Query Ok, 1 Row Affected (0.00 sec)
Mysql> Select * from testdata;
-- ------- -----
| ID | foo | BAR |
-- ------- -----
| 1 | Hello | 12345 |
-- ------- -----
1 row in set (0.00 sec)
MySQL>
2. Server.xml Configuration
.
Add this in between the context> Tag of the example content and the host> tag closing the localhost definition.
Debug = "5" reloadable = "true" crossContext = "true">
Configure your mysqld max_connections large enough to handle All of Your DB Connections. Set to 0 for no limit .-->
Set to -1 for no limit. See Also The DBCP Documentation on this And The MinevictableIdletimeMillis Configuration Parameter. ->
IN ms, in this example 10 seconds. An Exception Is Thrown IF THIS TIMEOUT IS EXCEEDED. SET to -1 to wait indefinitely. ->
Org.gjt.mm.mysql.driver - We Recommend USING CONNECTOR / J Though. Class Name for the Official MySQL Connector / J Driver is com.mysql.jdbc.driver. ->
The autoreconnect = true argument to the url makess sure what the the URL MAKES SURE THAT MM.MYSQL JDBC Driver Will Automatically Reconnect IF MySQLD CLOSED THE Connection. mysqld by Default Closes iDle Connections After 8 Hours. -> Maxactive = "100" maxidle = "30" maxwait = "10000" Username = "javauser" password = "javadude" driverclassname = "com.mysql.jdbc.driver" URL = "JDBC: mysql: // localhost: 3306 / javatest? AutoreConnect = true" /> Context> 3. Web.xml Configuration Now create a web-inf / web.xml for this test application. XMLns: xsi = "http://www.w3.org/2001/xmlschema-instance" XSI: schemAlocation = "http://java.sun.com/xml/ns/j2eehttp://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" Version = "2.4"> resource-ref> web-app> 4. Test Code Now Create a Simple Test.jsp Page for Use Later. <% @ Taglib Uri = "http://java.sun.com/jsp/jstl/sql" prefix = "SQL"%> <% @ Taglib Uri = "http://java.sun.com/jsp/jstl/core" prefix = "c"%> Select ID, Foo, Bar from testdata SQL: Query> hEAD>
Foo $ {row.foo}
Bar $ {row.bar}
c: foreach>
body>
html>
. That JSP page makes use of JSTL's SQL and Core taglibs You can get it from Sun's Java Web Services Developer Pack or Jakarta Taglib Standard 1.1 project -. Just make sure you get a 1.1.x release Once you have JSTL, copy jstl.jar And Standard.jar to your Web App's Web-INF / LIB DIRECTORY.
Finally Deploy Your Web App INTO $ CATALINA_HOME / WebApps Either As A Warfile Called Dbtest.war or Into a Sub-Directory Called Dbtest
Once Deployed, Point A Browser At http: // localhost: 8080 / dbtest / test.jsp to view the fruits of your hard work.