1.
try {
Class.forName("com.mysql.jdbc.Driver");
// localhost 意思是连接本地的数据库,或者也可以写IP地址,这样可以在同个局域网下连接其他电脑的数据库
// jdbc:mysql:是固定的
// 3306端口号
// root连接的数据库名
// 第三个参数就是数据库密码
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/jsp_db","root", "");
st = conn.createStatement();
rs = st.executeQuery(sql);
} catch (Exception e) {
// TODO: handle exception
}