JDBC 学习后,还记得的话 补上代码。
import java.sql.*;
public class ConnectDB{
private String url="jdbc:mysql://localhost:3306/lmos";
private String userName="root";
private String password="root";
private String jdbcName = "com.mysql.jdbc.Driver";
public Connection getCon() throws Exception {
Class.forName(jdbcName);
Connection con = DriverManager.getConnection(url,userName,password);
return con;
}
public void closeCon(Connection con)throws Exception{
if(con!=null)con.close();
}
}