Method for connecting to mysql Database Using JSP (1)

Source: Internet
Author: User



1. Software Download
Mysql
Download version: 4.1.11
Http://dev.mysql.com/downloads/mysql/4.1.html

JDBC driver
Download version: 3.1.8
Http://dev.mysql.com/downloads/connector/j/3.1.html

Mysql interface plug-in: mysql-front
Download this image: HongKong (the Chinese version will be installed later)
Http://www.mysqlfront.de/download.html

Ii. Software Installation
1. Install mysql
Please refer to documents

Http://info.mysql.cn/install/2006/0208/81.html

2. JDBC driver: mysql-connector-java-3.1.8
This is just a compressed package, does not need to install, as long as it is unzipped, what I use is folder mysql-connector-java-3.1.8 file: mysql-connector-java-3.1.8-bin.jar.

3. Mysql interface plug-in: mysql-front
This is an installation program. Follow the prompts to install it.

Iii. Environment Configuration
First, I want to explain that the current tomcat installation path is: D: Program FilesJavaTomcat; JDK installation path is: D: Program FilesJavaj2sdk.

The JDBC driver needs to be configured here. before configuring, you should first put the mysql-connector-java-3.1.8-bin.jar local hard disk somewhere (I put the place: D: Program FilesJavamysqlforjdbc), and then configure classpath according to the place you put, my configuration is as follows:

D: Program filesJavaj2sdklibools. jar;

D: Program FilesJavaj2sdklibmysql-connector-java-3.1.8-bin-g.jar;

D: Program FilesJavamysqlforjdbcmysql-connector-java-3.1.8-bin.jar

The purpose of this configuration is to allow your java application to find the driver connecting to mysql.

After configuring the environment variables, there is a very important step is to configure the driver for JSP Connection database, this is actually very simple, is the mysql-connector-java-3.1.8-bin. I copied jar files to some folders. I read a lot of information on the Internet and asked a lot of people about the various statements. I have integrated it and I have done all the work for the sake of insurance, haha, It is copying a K file, now list to copy the mysql-connector-java-3.1.8-bin.jar folder, as follows:
D: Program FilesJavaTomcatcommonlib
D: Program FilesJavaTomcatsharedlib

Iv. database usage

After installing Mysql, you can also pay attention to the following points (refer ):

Http://info.mysql.cn/install/2006/0208/82.html

As mentioned in the article, the most important thing after mysql is installed is to check whether the database has been started as a system service. Therefore, before performing database operations, you should check whether the database is started, at the start of the operating system, choose run> enter services. msc. Make sure that the mysql service you set has been started during installation. In this way, no connection error will be reported during database operations.

I mentioned a more convenient mysql interface plug-in, but this interface was found only after I started using mysql. At the beginning, I started to operate on it using command lines in dos. although the interface can also be used for database creation and permission setting, I think it is also an important skill to know how to use the command line. So let's start with the command line, how to use mysql. I will talk about mysql-front later.

Now I want to create a database shujuku in mysql and a table biao in the database. The specific command is as follows (assuming mysql is just installed)

1. Enter the dos Status (remember to run the command line in the bin directory under the mysql installation directory)

2. Connect to mysql

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.