First, you need a jar package to connect to Mysql.
String driver = "com. mysql. jdbc. driver "; // The URL points to the name of the database to be accessed String url =" jdbc: mysql: // 192.168.1.111: 3306/test "; // point to mysql String name = "platform" in the LAN server; String pass = "platform"; try {Class. forName (driver); // load the driver Connection conn = DriverManager. getConnection (url, name, pass); // connect to the database Statement statement = conn. createStatement (); // create a statement String SQL = "select * from User"; // query the SQL statement. ResultSet rs = statement.exe cuteQuery (SQL); // obtain the returned result set based on the query statement, which stores the required data while (rs. next () {String userName = rs. getString ("username"); // when the result set is read cyclically, You can traverse and obtain the data System. out. println (userName) ;}} catch (ClassNotFoundException e) {// TODO Auto-generated catch block e. printStackTrace ();} catch (SQLException e) {// TODO Auto-generated catch block e. printStackTrace ();}