1. Registration Driver
Drivermanager.registerdriver (New Com.mysql.jdbc.Driver ());
2. Get the connection
String url = "Jdbc:mysql://localhost:3306/jdbc";
String user = "root";
String password = "password";
Connection conn=drivermanage.getconnection (Url,user,password);
3. Get the operating environment
Statement st = Conn.createstatement ();
4. Processing results
Resultset rs = st.excutequery ("Select * Form MyUser");
while (Rs.next ()) {
Remove current record
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. Releasing Resources
Rs.close ();
St.close ();
Conn.close ();
JDBC Connection MySQL Database method