Get the App
SLTechnology News&Howtos  ›  Database  › 

How to install and use the mysql_jdbc driver of JSP

Shulou Source: shulou.com Published: 2022-05-31 14:01:08 10月03日 Update

This article introduces how to install and use the mysql_jdbc driver of JSP. The content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.

The editor only briefly describes the installation and use of mm.mysql.

Installation

1. Download mm.mysql

2. Extract to a drive, such as c:

3. Modify classpath and add the path to mm.mysql. For example, your original classpath may be:

; c:jdk1.2.2lib ools.jar;c:jdk1.2.2libdt.jar

After modification, it may be

; c:jdk1.2.2lib ools.jar;c:jdk1.2.2libdt.jar;C:mm.mysql.jdbc-2.0pre5

Programming

1. Register mm.mysql with DriverManager

The class of mm.mysql is called org.gjt.mm.mysql.Driver and must be written as

Class.forName (org.gjt.mm.mysql.Driver) .newInstance ()

2. Jdbc url parameter description

Url format: jdbc:mysql:// [hostname] [: port] / dbname [? param1=value1] [roomm2 = value2].

The default value of parameter name

User database user name none

Password database user password is missing

AutoReconnect whether to connect automatically when the database connection is lost. Value: true/false false.

MaxReconnects if autoReconnect is true, this parameter is the number of retries. The default is 3 times.

InitialTimeout if autoReconnect is true, this parameter is the number of seconds to wait before reconnecting 2

MaxRows sets the number of rows returned when querying. 0 means all 0.

Whether useUnicode uses unicode output, true/false false

CharacterEncoding if useUnicode, this parameter defines the encoding type. It is recommended to use 8859. None.

Prompt

Using useUnicode,characterEncoding at the same time can solve the Chinese problem of database output.

Such as: jdbc:mysql://localhost/test?user=root&useUnicode=true;characterEncoding=8859_1

A practical example, a simple example.

This jsp example uses a library that has only one table (address book).

Create database addressbook

Use addressbook

Create table addressbook (id int auto_increment primary key,name varchar (30), address varchar (255), phone varchar (20))

Insert record

Insert into addressbook (name,address,phone) values (jjx,zhejiang yuyao,0574-2222222)

Jsp code: absolute,ResultSet.TYPE_SCROOL_SENSITIVE and other directories are used in the code to test whether mm.mysql conforms to the jdbc 2.0 specification.

[@ more@]

Undefined

On how to install and use JSP's mysql_jdbc driver is shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Tags: Parameters data database driver example program driver code content more user help output good interest password just only at the same time address Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Xiaomi OPPO Reno Shulou Information Microsoft