2007年7月6日
通過exp導出與imp導入進行數據的備份轉移:
exp命令:
1 exp username/psw@TEST file=d:test.dmp full=y
2 exp username/psw@TEST file=d:test.dmp owner=(ly)
3 exp username/psw@TEST file= d:test.dmp tables=(grid1,grid2)
1其中一是將Test(與某一數據庫對應的oracle服務名)數據庫進行整體導出
2將屬于用戶ly的所有表導出
3將表grid1,與grid2導出
d:test.dmp是導出的文件地址
imp命令:
1 imp system/psw@TEST file=d:test.dmp
2 imp system/psw@TEST full=y file=d:test.dmp ignore=y
3 imp system/psw@TEST file=d:test.dmp tables=(grid1)
ignore=y表示如果被導入的數據庫中某個表已經存在就忽略不導入那個表
3表示只導入grid1這個表
在導入導出前要先測試下對應的數據庫是否是通的:tnsping test來測試,同樣test是服務名
所有命令可在cmd下執行
http://blog.csdn.net/techyang/archive/2005/08/09/448677.aspx(luanfengxia/arc/2006/05/20/746951.aspx)
public ActionForward add(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception {
String encoding = request.getCharacterEncoding();
if ((encoding != null) && (encoding.equalsIgnoreCase("utf-8")))
{
response.setContentType("text/html; charset=gb2312");//如果沒有指定編碼,編碼格式為gb2312
}
NodeForm theForm = (NodeForm) form;
String nodename=theForm.getNodename();
String note=theForm.getNote();
FormFile file = theForm.getTheFile1();//取得上傳的文件
FormFile file2=theForm.getTheFile2();
FormFile file3=theForm.getTheFile3();
Session session=null;
String forward="";
try
{
/*
* 取當前系統路徑
*/
String filePath = this.getServlet().getServletContext()
.getRealPath("/");
System.out.println("---------------------------------------"+filePath);
if(file.getFileSize()!=0){
ByteArrayInputStream stream = (ByteArrayInputStream) file.getInputStream();//把文件讀入
//ByteArrayOutputStream baos = new ByteArrayOutputStream();
/*
* 建立一個上傳文件的輸出流
*/
OutputStream bos = new FileOutputStream(filePath +
"UploadFiles\\"+file.getFileName());
request.setAttribute("fileName",filePath + "/"
+ file.getFileName());
int bytesRead = 0;
byte[] buffer = new byte[8192];
while ((bytesRead = stream.read(buffer, 0, 8192)) != -1)
{
bos.write(buffer, 0, bytesRead);//將文件寫入服務器
}
bos.close();
stream.close();
}if(file2.getFileSize()!=0){
ByteArrayInputStream stream2 = (ByteArrayInputStream) file2.getInputStream();
OutputStream bos2 = new FileOutputStream(filePath +
"UploadFiles\\"+file2.getFileName());//建立一個上傳文件的輸出流
int bytesRead2 = 0;
byte[] buffer2 = new byte[8192];
while ((bytesRead2 = stream2.read(buffer2, 0, 8192)) != -1)
{
bos2.write(buffer2, 0, bytesRead2);//將文件寫入服務器
}
bos2.close();
stream2.close();
}if(file3.getFileSize()!=0){
ByteArrayInputStream stream3 = (ByteArrayInputStream) file3.getInputStream();//把文件讀入
OutputStream bos3 = new FileOutputStream(filePath +
"UploadFiles\\"+file3.getFileName());//建立一個上傳文件的輸出流
int bytesRead3 = 0;
byte[] buffer3 = new byte[8192];
while ((bytesRead3 = stream3.read(buffer3, 0, 8192)) != -1)
{
bos3.write(buffer3, 0, bytesRead3);//將文件寫入服務器
}
bos3.close();
stream3.close();
}
Configuration config = new Configuration().configure();
SessionFactory factory = config.buildSessionFactory();
session = factory.openSession();
Transaction transaction = session.beginTransaction();
Node node=new Node();
node.setNodeName(nodename);
node.setXsdName(file.getFileName());
node.setXslName(file2.getFileName());
node.setXhtmlName(file3.getFileName());
node.setNote(note);
session.save(node);
session.flush();
session.clear();
forward="display";
transaction.commit();
}
catch (Exception e)
{
forward="error";
System.err.print(e);
e.printStackTrace();
}
finally{
session.close();
}
return mapping.findForward(forward);
}
"^\\d+$" //非負整數(正整數 + 0)
"^[0-9]*[1-9][0-9]*$" //正整數
"^((-\\d+)|(0+))$" //非正整數(負整數 + 0)
"^-[0-9]*[1-9][0-9]*$" //負整數
"^-?\\d+$" //整數
"^\\d+(\\.\\d+)?$" //非負浮點數(正浮點數 + 0)
"^(([0-9]+\\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\\.[0-9]+)|([0-9]*[1-9][0-9]*))$" //正浮點數
"^((-\\d+(\\.\\d+)?)|(0+(\\.0+)?))$" //非正浮點數(負浮點數 + 0)
"^(-(([0-9]+\\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\\.[0-9]+)|([0-9]*[1-9][0-9]*)))$" //負浮點數
"^(-?\\d+)(\\.\\d+)?$" //浮點數
"^[A-Za-z]+$" //由26個英文字母組成的字符串
"^[A-Z]+$" //由26個英文字母的大寫組成的字符串
"^[a-z]+$" //由26個英文字母的小寫組成的字符串
"^[A-Za-z0-9]+$" //由數字和26個英文字母組成的字符串
"^\\w+$" //由數字、26個英文字母或者下劃線組成的字符串
"^[\\w-]+(\\.[\\w-]+)*@[\\w-]+(\\.[\\w-]+)+$" //email地址
"^[a-zA-z]+://(\\w+(-\\w+)*)(\\.(\\w+(-\\w+)*))*(\\?\\S*)?$" //url