Backup: Send sql to mssqlserver:
backup database <your database name> to disk='backup 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 is located. mssql supports backup to network locations.
recover:
restore database <your database name> from disk='backup file name' with replace
It should be noted that when executing restore database, the database to be restored must not have any client connections, including itself (the connection that initiated the restore database command). To use restore, you can connect to the master library and then send the restore command.
Otherwise, it will definitely fail.
How to use it in jsp
-------------------------------------------------- ------------------------------------ You used this!
<%
You must first connect to the Connection object!
I just need to establish a connection with the database first and then directly use my statement in the jsp page.
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 statement to the database for execution.