How to use JDBC in JSP to join MYSQL_JSP programming
Source: Internet
Author: User
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.
/*
Tofu production is a boutique
Http://www.asp888.net Tofu Technology Station
If reproduced please retain the full copyright information
*/
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.