no message

main
이범준 7 months ago
parent e15a1a9fed
commit 433b0feead

@ -17,7 +17,7 @@ public class MakeExemptInfo {
private static String[] g_strDB = new String[4];
private final Logger logger = Logger.getLogger(MakeExemptInfo .class);
public static void main(String[] args) {
try {
@ -39,7 +39,7 @@ public class MakeExemptInfo {
g_strDB[1] = props.getProperty("db_connect");
g_strDB[2] = props.getProperty("db_id");
g_strDB[3] = props.getProperty("db_pw");
// 콘솔 출력
System.out.println(String.format("=== DB접속정보 : %s, %s, %s", g_strDB[1], g_strDB[2], g_strDB[3]));
} catch (Exception e) {
@ -52,9 +52,9 @@ public class MakeExemptInfo {
if(args.length != 2) {
System.err.println("총 2개의 args를 입력하지 않았습니다.");
System.err.println("파라미터 의미 없음");
System.exit(0);
System.exit(0);
}
double d = 0.0;
d = obj.runMakeExemptMstBin(Long.parseLong(args[0]), Long.parseLong(args[1]));
MakeScarInfo.logger.info("=== 파일 생성 소요시간 : " + d);
@ -65,12 +65,12 @@ public class MakeExemptInfo {
System.exit(0);
}
//
//
private Connection getOrclConn( ) throws Exception{
Class.forName(g_strDB[0]);
return DriverManager.getConnection(g_strDB[1], g_strDB[2], g_strDB[3]);
}
@SuppressWarnings({ "resource", "unused" })
private double runMakeExemptBin() throws Exception {
long start = System.currentTimeMillis(); // 작동 시간 측정용
@ -83,9 +83,8 @@ public class MakeExemptInfo {
try {
conn = (Connection) getOrclConn(); // Connection 생성 시 Connection으로 형변환
// prepareStatement를 PreparedStatement으로 형변환
// prepareStatement를 PreparedStatement으로 형변환
sql= "select * from (";
sql= sql + "select car_no, decode(EXEMPT_KBN, '0', '01', '2', '02', '3', '03', '4', '04', '5', '05', '6', '06') as exempt_cd, car_no_hex, document_no, enforce_date, end_date from exempt_cars_info";
sql= sql + " where to_char(enforce_date,'yyyymmdd') <= to_char(sysdate, 'yyyymmdd')";
@ -96,25 +95,25 @@ public class MakeExemptInfo {
ps = (PreparedStatement) conn.prepareStatement(sql);
rs = ps.executeQuery( sql );
rs.setFetchSize(10000);
Statement stmt = conn.createStatement(java.sql.ResultSet.TYPE_FORWARD_ONLY,java.sql.ResultSet.CONCUR_READ_ONLY);
stmt.setFetchSize(10000);
stmt.setFetchSize(10000);
rs = stmt.executeQuery( sql );
String str = "";
int n = 0;
File file = new File("./ExemptPL.bin");
FileOutputStream fos = new FileOutputStream(file);
FileOutputStream fos = new FileOutputStream(file);
while (rs.next()) {
n++;
if(n % 100 == 0) {
System.out.println("===== : " + n);
}
str = String.format("%010d%s%02d%s", n, "00", Integer.parseInt(rs.getString(2)), rs.getString(3));
fos.write(str.getBytes());
} // end while
} // end while
fos.close();
}catch(Exception e){
e.printStackTrace();
@ -123,10 +122,10 @@ public class MakeExemptInfo {
rs.close();
if(ps != null)
ps.close();
conn.close();
}
System.out.println("===== insert ok");
long end = System.currentTimeMillis(); // 작동시간 측정용
return (end - start) / 1000.0; // insertBatchFileToDB 실행에 걸린 시간
@ -141,7 +140,7 @@ public class MakeExemptInfo {
try {
conn = (Connection) getOrclConn(); // Connection 생성 시 Connection으로 형변환
// prepareStatement를 PreparedStatement으로 형변환
StringBuffer strSQL = new StringBuffer();
@ -154,18 +153,18 @@ public class MakeExemptInfo {
strSQL.append(" AND END_DATE >= SYSDATE");
strSQL.append(" ORDER BY CAR_NO");
strSQL.append(" )") ;
logger.info(strSQL.toString());
Statement stmt = conn.createStatement(java.sql.ResultSet.TYPE_FORWARD_ONLY,java.sql.ResultSet.CONCUR_READ_ONLY);
stmt.setFetchSize(10000);
stmt.setFetchSize(10000);
rs = stmt.executeQuery( strSQL.toString() );
String str = "";
int n = 0;
File file = new File("/gpta/source-app/cfs/relay_jar/data/IMMCARNO");
FileOutputStream fos = new FileOutputStream(file);
FileOutputStream fos = new FileOutputStream(file);
while (rs.next()) {
n++;
if(n % 10000 == 0) {
@ -174,8 +173,8 @@ public class MakeExemptInfo {
str = String.format("%s%s%s%s", rs.getString(1), rs.getString(2), rs.getString(3), rs.getString(4));
fos.write(str.getBytes());
} // end while
} // end while
fos.close();
logger.info( strSQL.toString());
@ -186,12 +185,12 @@ public class MakeExemptInfo {
return (end - start) / 1000.0; // insertBatchFileToDB 실행에 걸린 시간
}
String sql = "update TB_CFS_MST_FLAG set EXEMPT_FLAG = '1', EXEMPT_SENDTIME = SYSDATE ";
ps = (PreparedStatement) conn.prepareStatement(sql);
ps.executeUpdate();
conn.commit();
}catch(Exception e){
e.printStackTrace();
}finally{
@ -199,7 +198,7 @@ public class MakeExemptInfo {
rs.close();
if(ps != null)
ps.close();
conn.close();
}
@ -207,15 +206,15 @@ public class MakeExemptInfo {
long end = System.currentTimeMillis(); // 작동시간 측정용
return (end - start) / 1000.0; // insertBatchFileToDB 실행에 걸린 시간
}
private int setFtpData(File file, String fileNm) {
FTPUtil sftp = new FTPUtil();
this.logger.debug("======== 업로드 시작 : " + fileNm);
sftp.init("175.193.201.56", "tmax","tmax1234");
Map<String, String> map = new HashMap<String, String>();
map.put("return", "0");
@ -224,17 +223,17 @@ public class MakeExemptInfo {
} catch (Exception e) {
e.printStackTrace();
}
this.logger.debug("======== : " + map.get("return"));
int nReturn = Integer.parseInt(map.get("return"));
sftp.disconnect();
this.logger.debug("======== 업로드 끝 : " + nReturn);
return nReturn;
}
}

Loading…
Cancel
Save