From 373acf97a7b2c24667bd16ed24054b2156f45a04 Mon Sep 17 00:00:00 2001 From: kuboryu Date: Sat, 13 May 2017 07:25:44 +0900 Subject: [PATCH] 20170513 --- com/rapide_act/CmnProps.java | 2 + com/rapide_act/RapideMetaLoader.java | 22 +++++- com/rapide_act/RapideMetaUnloader.java | 138 +++++++++++++++++++-------------- 3 files changed, 99 insertions(+), 63 deletions(-) diff --git a/com/rapide_act/CmnProps.java b/com/rapide_act/CmnProps.java index 10b2106..1825374 100644 --- a/com/rapide_act/CmnProps.java +++ b/com/rapide_act/CmnProps.java @@ -39,6 +39,8 @@ public class CmnProps{ protected static final String [] DB_TYPE_NAME = {"ORACLE", "SQLSERVER", "MYSQL", "DB2", "POSTGRESQL", "HIRDB"}; protected static final String [] DB_SQL_QUOTEDS = {"\"", "[", "`", "\"", "\"", "\""}; protected static final String [] DB_SQL_QUOTEDE = {"\"", "]", "`", "\"", "\"", "\""}; + protected static final String [] SQL_TERMINATOR = {";", System.getProperty("line.separator") + "GO", ";", ";", ";", ";"}; + protected static final String [] SQL_PREFIX = {"@", ":r ", "", "", "", ""}; protected static final int MASK_PTN_ALL = 0; protected static final int MASK_PTN_ALT = 1; protected static final int MASK_PTN_EDGE = 2; diff --git a/com/rapide_act/RapideMetaLoader.java b/com/rapide_act/RapideMetaLoader.java index a817d6f..81e0fb4 100644 --- a/com/rapide_act/RapideMetaLoader.java +++ b/com/rapide_act/RapideMetaLoader.java @@ -73,7 +73,7 @@ public class RapideMetaLoader{ cp = new CmnProps(); cp.setProperty(database); - if (cp.dbType != cp.DB_TYPE_ORACLE){ + if (cp.dbType > cp.DB_TYPE_SQLSERVER || cp.dbType <0){ throw new Exception("ƒf[ƒ^ƒx[ƒX‚ª‘ΏۊO‚Å‚·B[" + cp.DB_TYPE_NAME[cp.dbType] + "]"); } if(cp.inFolder != null){ @@ -180,12 +180,22 @@ public class RapideMetaLoader{ if (infile.exists()){ br = new BufferedReader(new InputStreamReader(new FileInputStream(_infile), _cp.fileEncoding)); while((strLine=br.readLine()) != null){ - strMltLine += _cp.inColLineSeparator + strLine; + if (_cp.dbType == _cp.DB_TYPE_SQLSERVER){ + if(!strLine.equals("GO")){ + strMltLine += _cp.inColLineSeparator + strLine; + } + } else { + strMltLine += _cp.inColLineSeparator + strLine; + } } if(_isReplace){ if(!strMltLine.equals("")){ try { - _stmt = _dao.prepareSql(strMltLine.replaceAll("\r","")); + if (_cp.dbType == _cp.DB_TYPE_ORACLE){ + _stmt = _dao.prepareSql(strMltLine.replaceAll("\r","")); + } else { + _stmt = _dao.prepareSql(strMltLine); + } _stmt.executeUpdate(); if(_stmt != null){ _stmt.close(); @@ -202,7 +212,11 @@ public class RapideMetaLoader{ for(int l = 0;l1)CmnUtils.debugPrint("'" + strSplit[0][1] + "'"); pw[0] = new PrintWriter(new BufferedWriter(new FileWriter(new File(subFolder + "/" + strSplit[0][0] + ".sql")))); @@ -875,7 +889,7 @@ public class RapideMetaUnloader{ strContents = alData2.get(0).trim(); strSplit[1] = CmnUtils.split(strContents, lineSeparator); for(int i=0;i1)CmnUtils.debugPrint("'" + strSplit[0][1] + "'"); pw[0] = new PrintWriter(new BufferedWriter(new FileWriter(new File(subFolder + "/" + strSplit[0][0] + ".sql")))); - pw[0].println("/* " + strSplit[0][0] + " */"); - pw[0].print("CREATE OR REPLACE "); + if (cp.dbType == cp.DB_TYPE_ORACLE){ + pw[0].println("/* " + strSplit[0][0] + " */"); + pw[0].print("CREATE OR REPLACE "); + } stmt = dao.prepareSql(sql_proc[cp.dbType]); stmt.setString(1,strSplit[0][1]); stmt.setString(2,strSplit[0][0]); @@ -914,9 +930,13 @@ public class RapideMetaUnloader{ alData = dao.getArrayList(); for(int i=0;i