时间:2021-07-01 10:21:17 帮助过:11人阅读
2.获取连接
String url = "jdbc:mysql://localhost:3306/jdbc";
String user = "root";
String password = "password";
Connection conn=DriverManage.getConnection(url,user,password);
3.得到运行环境
Statement st = conn.createStatement();
4.处理结果
Resultset rs = st.excuteQuery("select * form myuser");
while(rs.next()){
//去除当前记录
int userID =rs.getInt("userID");
String userName = rs.getString("userName");
String userPass = rs.getString("userPass");
String email = rs.getString("email");
Date birthday = rs.getDate("birthday");
system.out.println(userID+"\t"+userName+"\t"+userPass+"\t"+email+"\t"+birthday);
}
5.释放资源
rs.close();
st.close();
conn.close();
jdbc连接MySQL数据库方法
标签:jdbc