Home > Java > javaTutorial > body text

What is the password for jdbc:mysql?

anonymity
Release: 2020-09-17 09:36:50
Original
4043 people have browsed it

What is the password for jdbc:mysql?

jdbc: mysql is the driver for connecting to the MySQL database. The password is the password of the database management user to be connected. When opening the connection, use the database connection, user name, and password to connect. .

The following describes how to install JDBC:

To use JDBC to connect to MySQL, you need a driver package:

You can download it here ( In fact, after completely installing MySQL, you can find this package in the installation path): http://www.mysql.com/products/connector/

After decompressing, unzip the mysql-connector-java-XXX-bin. Add the jar file to the lib of the Web Project:

What is the password for jdbc:mysql?

JDBC code writing

First, you need to load the driver:

// 加载驱动Class.forName("com.mysql.jdbc.Driver");
Copy after login

Then, establish a connection:

String dbUrl = "jdbc:mysql://localhost:3306/mydatabase1";
String dbUser = "your_username";
String dbPwd = "your_password";// 打开数据库连接con = DriverManager.getConnection(dbUrl, dbUser, dbPwd);
Copy after login

Note that the port number and database name (mydatabase1) may need to be modified.

JDBC connects to different databases:

What is the password for jdbc:mysql?

#You can then execute the SQL statement.

Finally remember to close the resource.

The above is the detailed content of What is the password for jdbc:mysql?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!