- package com.itheima.test;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.Statement;
- public class DbTest {
- String driver = "com.mysql.jdbc.Driver";
- String url = "jdbc:mysql://127.0.0.1:3306/student";
- String user = "root";
- String password = ""; //这里报错
- try{
- Class.forName(driver);
- Connection conn = DriverManager.getConnection(url, user, password);
- if(!conn.isClosed())
- System.out.println("Succeeded connecting to the Database!");
- Statement statement = conn.createStatement();
- }catch(Exception e){
- e.printStackTrace();
- }
- }
- }
复制代码
|
|