请问谁有做过jsp oracle数据库备份的模块吗?请问这个怎么备份数据库呢?
解决方案 »
- 40分悬赏求助:西安公交数据
- weblogic91问题: exceeds the configured maximum
- Hibernate HSQL 怎么在生成的SQL 中的 字符串常量前加上 N 前缀以标识为Unicode编码
- 我想把JSP中JAVA片段得到的值通过超连接或者提交按钮传到对应的ACTION类中 怎么实现?(有代码片段)
- DWR运行效率问题
- 关于URL和SESSION 的问题,请高手指教
- jndiContext.lookup("java:comp/env/ejb/CabinHomeRemote"); 的comp/env/ejb是怎么意思
- strut1.1+jakarta-tomcat-5.0.28报错.
- 如何用jdk对一个含有包的就java程序进行编译阿?
- cmp bean的错误
- 怎么弄到这个效果,用swing 组件和jsp脚本能做成吗?
- ssh操作出错,请高手指示
数据库备份String webtruepath=getServletContext().getRealPath(request.getServletPath());//取Servlet的真实路径
java.io.File file=new java.io.File(webtruepath);
file=file.getParentFile();
String path=file.getPath()+"\\..\\WEB-INF\\lib\\"+name+".dbbak";//name文件名
String bakSQL="backup database school to disk=? with init";//SQL语句
java.sql.PreparedStatement bak=DBS.getConnection().prepareStatement(bakSQL);
bak.setString(1,path);//path必须是绝对路径
if(!bak.execute())over="备份成功";
else over="备份失败";
bak.close();
数据库恢复
if(!DBS.close()){
over="关闭所有链接失败";
}else{
String webtruepath=getServletContext().getRealPath(request.getServletPath());
java.io.File file=new java.io.File(webtruepath);
file=file.getParentFile();
String path=file.getPath()+"\\..\\WEB-INF\\lib\\"+name;
String reSQL="restore database school from disk=? with replace";
Class.forName(DBInf.getDriverClassName());
java.sql.Connection con=DriverManager.getConnection(DBInf.getMester());
java.sql.PreparedStatement reStmt=con.prepareStatement(reSQL);
reStmt.setString(1,path);//path必须是绝对路径
if(!reStmt.execute())over="恢复成功";
else over="恢复失败";
reStmt.close();
con.close();
}恢复的时候,有点烦,要关闭所有与数据库的连接,这里我连的是mestar,其实可以
jdbc:microsoft:sqlserver://localhost:1433;user=username;password=pass
连接数据库服务器,不连指定的数据库.这样也可以.
http://wenku.baidu.com/view/4bbef73610661ed9ad51f394.html希望对你有帮助