1.注册数据库驱动
Class.forName("com.mysql.jdbc.Driver");

2.获取连贯
`Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/jt_db?characterEncoding=utf-8",

            "root", "root");`           

3.获取传输器
Statement stat = conn.createStatement();

4.利用传输器发送SQL到服务器执行,返回执行后果
`String sql = "select * from account";

    ResultSet rs = stat.executeQuery(sql);`    

5.处理结果

6.避免注入攻打办法
`ComboPooledDataSource pool = new ComboPooledDataSource();
Connection conn = pool.getConnection();
String sql = "select * from user";
PreparedStatement ps =conn.prepareStatement(sql);
ResultSet rs = ps.executeQuery();`