importjava.sql.Connection;importjava.sql.DriverManager;importjava.sql.ResultSet;importjava.sql.SQLException;importjava.sql.Statement;public classJDBC01 {public static void main(String[] args) throwsSQLException {//selectAll();
System.out.println(selectByUernamePassword("Gary","123"));
}public static void selectAll() throwsSQLException {//注册驱动 使用驱动连接数据库
Connection con = null;
Statement stmt= null;
ResultSet rs= null;try{
Class.forName("com.mysql.jdbc.Driver");//String url ="jdbc:mysql://localhost:3306/garysql";//指定编码查询数据库
String url ="jdbc:mysql://localhost:3306/garysql?useUnicode=true&characterEncoding=UTF8&useSSL=false";
String user= "root";
String password= "123456";//建立和数据库的连接
con =DriverManager.getConnection(url,user,password);//数据库的增删改查
<