日期:2014-05-20 浏览次数:20742 次
String sql="USE cusmsgmgt"+"EXEC sp_addumpdevice 'disk','BAK','E:\\bak\\bak.dat'" +"BACKUP DATABASE rabc TO BAK"; Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance(); System.out.println("加载驱动成功!"); String dbURL="jdbc:sqlserver://localhost:53837; DatabaseName=cusmsgmgt";//连接数据库 String userName = "sa"; String userPwd = "123"; Connection con=DriverManager.getConnection(dbURL,userName,userPwd); System.out.println("连接数据库成功!"); Statement stat=con.createStatement(); stat.execute(sql); System.out.println("备份成功!");