One, the code is as follows
private void BackupDatabase () {//TODO auto-generated method stubjava.sql.PreparedStatement PS = null; Java.sql.Connection cn = NULL; ResultSet rs = null;try {//Class.forName ("Com.microsoft.jdbc.sqlserver.SQLServerDriver"); Class.forName ("Com.mysql.jdbc.Driver"). newinstance (); cn = Drivermanager.getconnection ("Jdbc:mysql://localhost : 3306/learn?user=root&password=&useunicode=true&characterencoding=utf8 ");p s = cn.prepareStatement (" Backup database Learn to disk= ' D:/12345.bak '); int i= ps.executeupdate (); System.out.println (i); if (i>=1) {System.out.println ("Database Backup: Success");} else {System.out.println ("Database backup: Failed");}} catch (Exception e) {//TODO auto-generated catch Blocke.printstacktrace ();} finally {try {ps.close (); Cn.close ();} catch ( SQLException e) {e.printstacktrace ();}}}
MySQL database __jdbc direct operation __preparedstatement__ Database backup