jdbc连接mysql
时间:2021-07-01 10:21:17
帮助过:4人阅读
public class Test {
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
Class.forName(
"com.mysql.jdbc.Driver");
Connection conn=DriverManager.getConnection(
"jdbc:mysql://localhost:3306/boooks",
"root",
"tiger");
Statement st=
conn.createStatement();
ResultSet rs=st.executeQuery(
"select * from tb_user");
while(rs.next()){
System.out.print(rs.getInt(
1)+
"\t");
System.out.print(rs.getString(
2)+
"\t");
System.out.print(rs.getString(
3)+
"\t");
System.out.println(rs.getString(
4));
}
rs.close();
st.close();
conn.close();
}
}
jdbc连接mysql
标签:tin root out .exe public ati exec state create