Java-Database(Mysql) Interface
- Java Servlet or Applet can access SQL database server through the JDBC API.
- MySQL Connector/J JDBC driver allow java programs to connect to the MySQL
database server.
- Here we show the configuration steps and include a demo of such Java-Database
access with JSP custom tag.
Installation/Configuration of MySQL Connector/J
- Download MySQL Connector/J, the official JDBC driver for MySQL, from http://www.mysql.com/downloads/api-jdbc-stable.html
- See directory structure at http://cs.uccs.edu/~cs526/tomcat/jakarta-tomcat-4.1.12/webapps/tomcat-docs/appdev/dbjsp/mysql-connector-java-2.0.14/
- The READM file there includes info about installation and basic usage.
- Put mysql-connector-j-2.0.14-bin.jar in your classpath, either by adding
the
FULL path to it to your CLASSPATH enviornment variable, or putting it
in $JAVA_HOME/jre/lib/ext
- If you are using a servlet engine or application server, you will have
to read your vendor's documentation for more information on how to
configure third-party class libraries, as most application servers
ignore the CLASSPATH environment variable. If you are developing
servlets and/or JSPs, and your application server is J2EE-compliant,
you should put the driver's .jar file in the WEB-INF/lib
subdirectory
of your webapp, as this is the standard location for third party
class libraries in J2EE web applications.
Custom Tag JSP-Database Demo