/**
* Created with IntelliJ IDEA.
* User: Administrator
* Date: 13-12-23
* Time: 上午10:05
* To change this template use File | Settings | File Templates.
*/
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream; //import java.io.FileNotFoundException;
//import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
public class chanageSql {
public static void main(String[] args){
try {
BufferedReader bufReader =
new BufferedReader(
new InputStreamReader(
new FileInputStream(
new File("d:/ats_2.0.7_nibl_20131114_20131215.sql"))));
StringBuffer strBuf = new StringBuffer();
for (String tmp1 = null; (tmp1 = bufReader.readLine()) != null; tmp1 = null) {
// 替换UC操作
String tmp = new String(tmp1.toString().getBytes("UTF-8"));
tmp = tmp.replaceAll("FROM HSI_RIGHT", "FROM ats002.HSI_RIGHT");
tmp = tmp.replaceAll("INTO HSI_RIGHT", "INTO ats002.HSI_RIGHT");
tmp = tmp.replaceAll("FROM HSI_MENURIGHT", "FROM ats002.HSI_MENURIGHT");
tmp = tmp.replaceAll("FROM TSVCSQL", "FROM ats002.TSVCSQL");
tmp = tmp.replaceAll("INTO TSVCSQL", "INTO ats002.TSVCSQL");
tmp = tmp.replaceAll("FROM TSVCINTERFACE", "FROM ats002.TSVCINTERFACE");
tmp = tmp.replaceAll("INTO TSVCINTERFACE", "INTO ats002.TSVCINTERFACE");
tmp = tmp.replaceAll("FROM TSVCVIEWCONFIG", "FROM ats002.TSVCVIEWCONFIG");
tmp = tmp.replaceAll("INTO TSVCVIEWCONFIG", "INTO ats002.TSVCVIEWCONFIG");
tmp = tmp.replaceAll("UPDATE TSVCINTERFACE", "UPDATE ats002.TSVCINTERFACE");
// 替换权限操作
tmp = tmp.replaceAll("from tsys_subtrans", "from ats002.tsys_subtrans");
tmp = tmp.replaceAll("into tsys_subtrans", "into ats002.tsys_subtrans");
tmp = tmp.replaceAll("FROM tsys_role_right", "FROM ats002.tsys_role_right");
tmp = tmp.replaceAll("into tsys_role_right", "into ats002.tsys_role_right");
System.out.println(tmp);
strBuf.append(tmp);
strBuf.append(System.getProperty("line.separator"));
}
bufReader.close();
String strBuf2 = new String(strBuf.toString().getBytes("UTF-8"));
// System.out.println(strBuf2);
PrintWriter printWriter = new PrintWriter("d:/chanage_ats_2.0.7_nibl_20131114_20131215.sql");
printWriter.write(strBuf2.toString().toCharArray());
printWriter.flush();
printWriter.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}