Using JSP to realize backup and recovery of Sqlserve database

Source: Internet
Author: User
Tags connect mssqlserver tostring backup
js|sql| Backup | recovery | data | database

Backup: Send SQL to MSSQLServer:
Backup Database <your database name> to disk= ' backed up file name ' with Init
Note: 1. The backup file name must be an absolute path.
2. The backup file can only be the path on the machine where MSSQLServer resides, and MSSQL supports backup to the network location.

Recovery:
Restore Database <your database name> from disk= ' backup filename ' with replace
Note that when the restore database is executed, the databases to be restored must have no client connections, including itself (the connection that originated the Restore Database command). Using restore, you can connect to the master library and then send the Restore command. Otherwise, it must fail.

How to use in JSP?
--------------------------------------------you use this!
<%
To connect the Connection object first!
is to establish a connection with the database first.
And then in the JSP page directly with my statement on it.
try{
String sql= "BACKUP database xncsims to disk= ' D:\\xncback.dat '";

St=con.createstatement ();

Rs=st.executequery (SQL);

}
catch (SQLException e) {System.out.println (e.tostring ());}
catch (Exception e) {System.out.println (e.tostring ());}

%>

Rs=st.executequery (SQL);
This is where you send your SQL statements to the database for execution.



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.