Js|mysql
In the previous article, tofu once said a JDBC-ODBC bridge to connect the database of the article a JavaBean (can be called in the Jsp), because the efficiency of this connection to the database is very low, so everyone actually in the use of the time are used JDBC, Now I'm going to talk to you about how to use JDBC to connect to a MySQL article under Win2K.
First is the MySQL jdbc driver download, download address in: http://download.sourceforge.net/pub/mirrors/mysql/Downloads/Contrib/mm.mysql.jdbc-1.2c.tar.gz
At the end of the download, the zip file will be extracted to any directory, we assume that the directory is: d:\jdbc,ok! below we set up classpath to ensure that our webserver access to this driver
Set the method as follows:
1. My Computer-> system-> Set the environment variable if there is already classpath edit it, otherwise add a classpath
2. Set the value of Classpath: D:\jdbc\mm.mysql.jdbc-1.2c\mysql_comp.jar
3. Reboot the server
When the boot is complete, you can
After the JDBC Setup is complete, many people may not be clear whether our JDBC is really installed successfully, we will use a JDBC connection MySQL program to check whether we are the actual installation success code as follows:
<%@ page contenttype= "text/html;charset=gb2312"%>
<%
Java.sql.Connection Conn;
Java.lang.String strconn;
Class.forName ("Org.gjt.mm.mysql.Driver"). newinstance ();
sqlconn= java.sql.DriverManager.getConnection ("Jdbc:mysql://localhost/test", "Root", "");
%>
The code is simple, but it has completed our test of MySQL JDBC installation success or not.
Thanks to the great help of the Oriental snake, this article has been completed.