JDBC MySQL data link eight steps:
Package com.company; Import the java.sql.Connection; Import the java.sql.Driver; Import the java.sql.DriverManager; Import the java.sql.Statement; public class the Main { public static void main (String [] args) throws Exception { // the Write your code here Wallpaper // 1. import the driver package jar package jar package download link: https://dev.mysql.com/downloads/connector/j/5.1.html download the zip file, extract the files copied to the lib, then right-click libs aS Library is set to the Add // 2. registration driver Class.forName ( "com.mysql.cj.jdbc.Driver" ); //3. Get the database connection object database db2 is your name behind your mysql root user name is your mysql password Connection conn = DriverManager.getConnection ( "jdbc: mysql: // localhost:? 3306 / db2 serverTimezone = GMT% 2B8" , "the root", "123" ); // 4. defined sql statement String sql = "Update DB1 SET = 101 class = WHERE SnO. 1" ; // 5. the object acquired execute sql the statement the statement stmt = conn.createStatement ( ); // 6. execute SQL int COUNT = stmt.executeUpdate (SQL); // 7. The processing result System.out.println (COUNT); // 8. The release resources stmt.close (); conn.Close () ; } }