Home  >  Article  >  Java  >  What is the password for jdbc:mysql?

What is the password for jdbc:mysql?

anonymity
anonymityOriginal
2019-05-08 16:39:114017browse

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");

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);

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!

Statement:
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