Home >Java >javaTutorial >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:
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:
#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!