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();`
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。