import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; public class JDBCDatabaseConnection { private static final String DBDRIVER = "org.gjt.mm.mysql.Driver"; private static final String DBURL = "jdbc:mysql://localhost:3306/test"; private static final String DBUSER = "root"; // root账号 private static final String PASSWORD = "admin"; // 数据库密码 public static void main(String[] args) throws Exception { Class.forName(DBDRIVER) ; Connection conn = DriverManager.getConnection(DBURL, DBUSER, PASSWORD) ; System.out.println(conn); conn.close() ; } }