Package COM. huawei. mySQL; import Java. SQL. connection; import Java. SQL. drivermanager; import Java. SQL. preparedstatement; import Java. SQL. resultset; import Java. SQL. sqlexception; public class mysqltest {public static void main (string [] ARGs) throws sqlexception {connection conn = NULL; preparedstatement stmt = NULL; resultset rs = NULL; try {class. forname ("com. mySQL. JDBC. driver "); Conn = drivermanager. getconn Ection ("JDBC: mysql: // localhost: 3306/test", "root", "123"); stmt = conn. preparestatement ("select * From person where id =? "); Stmt. setint (1, 10); RS = stmt.exe cutequery (); While (RS. next () {system. out. println (RS. getint ("ID"); system. out. println (RS. getstring ("name"); system. out. println ("----------------------------") ;}} catch (classnotfoundexception e) {e. printstacktrace ();} catch (sqlexception e) {e. printstacktrace ();} finally {If (RS! = NULL) Rs. Close (); If (stmt! = NULL) stmt. Close (); If (Conn! = NULL) Conn. Close ();}}}