diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2fa9909 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +/target +/.settings +/.classpath +/.project +/.idea +*.iml +/build \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..7a65526 --- /dev/null +++ b/pom.xml @@ -0,0 +1,277 @@ + + 4.0.0 + kr.co.mantech + acc-webapp-mvn + 0.0.1-SNAPSHOT + acc-webapp-mvn + Maven Accordion Webapp Test + + UTF-8 + 1.8 + 1.8 + 1.8 + + + 4.3.14.RELEASE + 1.8.9 + + + 2.2.1 + 1.2.1 + 3.0.1 + + + 1.7.25 + 1.2.17 + 3.0.3 + + + 2.10 + 3.7.0 + 1.6.0 + + + 1.4.187 + 2.7.2 + + + + + + + org.springframework + spring-context + ${org.springframework-version} + + + + commons-logging + commons-logging + + + + + org.springframework + spring-webmvc + ${org.springframework-version} + + + + + org.aspectj + aspectjrt + ${org.aspectj-version} + + + + + org.slf4j + slf4j-api + ${org.slf4j-version} + + + org.slf4j + jcl-over-slf4j + ${org.slf4j-version} + runtime + + + org.slf4j + slf4j-log4j12 + ${org.slf4j-version} + runtime + + + log4j + log4j + ${log4-version} + + + javax.mail + mail + + + javax.jms + jms + + + com.sun.jdmk + jmxtools + + + com.sun.jmx + jmxri + + + runtime + + + + + + + javax.inject + javax.inject + 1 + + + + + + + javax.servlet + javax.servlet-api + ${servlet.version} + provided + + + javax.servlet.jsp + javax.servlet.jsp-api + ${jsp.version} + provided + + + javax.servlet.jsp.jstl + javax.servlet.jsp.jstl-api + ${jstl.version} + + + org.glassfish.web + javax.servlet.jsp.jstl + ${jstl.version} + + + + jstl-api + javax.servlet.jsp.jstl + + + + + + + + + junit + junit + 4.11 + test + + + + org.apache.tiles + tiles-jsp + ${org.apache.tiles.version} + + + org.apache.tiles + tiles-core + ${org.apache.tiles.version} + + + + + com.h2database + h2 + ${dbh2.version} + + + + + + org.mariadb.jdbc + mariadb-java-client + ${mariadb.version} + + + + + + commons-dbcp + commons-dbcp + 1.4 + + + + + + + + + + + + + acc-webapp-mvn + + + + maven-clean-plugin + 3.1.0 + + + + maven-resources-plugin + 3.0.2 + + + maven-compiler-plugin + 3.8.0 + + + maven-surefire-plugin + 2.22.1 + + + maven-war-plugin + 3.2.2 + + + maven-install-plugin + 2.5.2 + + + maven-deploy-plugin + 2.8.2 + + + + + + \ No newline at end of file diff --git a/src/main/java/kr/co/mantech/common/DBManager.java b/src/main/java/kr/co/mantech/common/DBManager.java new file mode 100644 index 0000000..fa7af86 --- /dev/null +++ b/src/main/java/kr/co/mantech/common/DBManager.java @@ -0,0 +1,158 @@ +package kr.co.mantech.common; + +import java.sql.*; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; + +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import javax.sql.DataSource; + +public class DBManager { + + private static final Logger logger = Logger.getLogger(DBManager.class.getName()); + private Context ctx; + private static DBManager instance; + + + + public DBManager() + { + + } + + + public static DBManager getInstance() + { + if (instance==null) + { + instance=new DBManager(); + } + return instance; + + } + + + + + public Connection getConnection(String dataSource) + { + DataSource ds = null; + Connection con = null; + try + { + ctx = new InitialContext(); + // get each datasource + ds=(javax.sql.DataSource)ctx.lookup(dataSource); + // get each connection + con = ds.getConnection(); + + }catch (NamingException e) + { + logger.log(Level.SEVERE,e.getMessage()); + e.printStackTrace(); + } catch (SQLException e) { + logger.log(Level.SEVERE,e.getMessage()); + e.printStackTrace(); + } + logger.log(Level.INFO, "# getConnection "); + logger.log(Level.INFO, "#########################"); + + return con; + + + } + + public void updateSQL(PreparedStatement ps) throws Exception + { + + ps.executeUpdate(); + logger.log(Level.INFO, "# updateSQL "); + + } + + public ResultSet selectSQL(PreparedStatement ps) + { + ResultSet rs = null; + try { + rs = ps.executeQuery(); + + } catch (SQLException e) { + logger.log(Level.SEVERE,e.getMessage()); + e.printStackTrace(); + } + logger.log(Level.INFO, "# selectSQL "); + logger.log(Level.INFO, "# resultSet: " + rs); + + return rs; + } + + public void insertSQL(PreparedStatement ps) throws Exception + { + ps.executeUpdate(); + logger.log(Level.INFO, "# insertSQL "); + + } + + public void close(Connection dataSource) + { + if(dataSource != null) + { + try + { + dataSource.close(); + }catch(SQLException e) + {e.printStackTrace();} + } + logger.log(Level.INFO, "# close DataSource "); + } + + public void close(Connection dataSource, ResultSet rs, PreparedStatement ps) + { + + + if(dataSource != null) + { + try + { + dataSource.close(); + }catch(SQLException e) + {e.printStackTrace();} + } + + if(ps != null) + { + try + { + ps.close(); + }catch(SQLException e) + {e.printStackTrace();} + } + + if(rs != null) + { + try + { + rs.close(); + }catch(SQLException e) + {e.printStackTrace();} + } + + logger.log(Level.INFO, "# close DataSource, ResultSet , ps "); + } + + public void close(PreparedStatement ps) + { + if(ps != null) + { + try + { + ps.close(); + }catch(SQLException e) + {e.printStackTrace();} + } + logger.log(Level.INFO, "# close PreparedStatement "); + } +} diff --git a/src/main/java/kr/co/mantech/common/HeapLeakManager.java b/src/main/java/kr/co/mantech/common/HeapLeakManager.java new file mode 100644 index 0000000..6ed0241 --- /dev/null +++ b/src/main/java/kr/co/mantech/common/HeapLeakManager.java @@ -0,0 +1,161 @@ +package kr.co.mantech.common; + +import java.util.*; +import javassist.*; + +public class HeapLeakManager { + + private boolean infinite; + private int count; + private int classCount=0; + public enum CheckType {Heap, Perm}; + ArrayList myArrayList = new ArrayList(); + String temp="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; + String className="kr.or.tta.bmt.F12.TEMP"; + + private CheckType type; + + + public HeapLeakManager() + { + this.infinite = false; + this.count = 1000; + this.type= CheckType.Heap; + } + + public HeapLeakManager(boolean infinite, int count, CheckType type ) + { + this.infinite = infinite; + this.count = count; + this.type=type; + } + + + public static Class generate(String name) + throws Exception + { + ClassPool pool = ClassPool.getDefault(); + + return pool.makeClass(name).toClass(); + } + public HashMap makeHeapLeak() throws Exception + { + HashMap hm; + if (this.infinite) + { + while(true){ + Thread.sleep(500); + for(int i=0;i<2000 ; i++) + { + myArrayList.add(new StringBuilder(temp)); + } + printHeapInfo(); + } + + } + else + { + for(int i=0;i(); + long heapSize = Runtime.getRuntime().totalMemory()/1024/1024; + long freeHeapSize = Runtime.getRuntime().freeMemory()/1024/1024; + ClassLoader myCL = Thread.currentThread().getContextClassLoader(); + if (myCL != null) { + System.out.println("ClassLoader: " + myCL); + + Class CL_class = myCL.getClass(); + while (CL_class != java.lang.ClassLoader.class) { + CL_class = CL_class.getSuperclass(); + } + java.lang.reflect.Field ClassLoader_classes_field = CL_class.getDeclaredField("classes"); + ClassLoader_classes_field.setAccessible(true); + Vector classes = (Vector) ClassLoader_classes_field.get(myCL); + + System.out.println(classes.size()); + System.out.printf("Number of Loaded Class is %d \n", classes.size()); + /* + for (Iterator iter = list(myCL); iter.hasNext();) { + System.out.println("\t" + iter.next()); + }*/ + //myCL = myCL.getParent(); + + hm.put("classesSize", classes.size()); + } + + hm.put("heapSize", heapSize); + hm.put("freeHeapSize", freeHeapSize); + hm.put("ArraySize", myArrayList.size()); + + System.out.printf("HeapSize = %d MB\n", heapSize); + System.out.printf("FreeHeapSize = %d MB \n", freeHeapSize); + System.out.printf("ArraySize = %d �� \n", myArrayList.size()); + + + + return hm; + + } + + public HashMap doLeak() throws Exception + { + HashMap hm = null; + switch (this.type) { + case Perm: + hm = makePermLeak(); + break; + default: + hm = makeHeapLeak(); + break; + } + return hm; + } + + public static void main(String args[]) throws Exception + { + HeapLeakManager hlm = new HeapLeakManager(true, 1000, CheckType.Heap); + hlm.doLeak(); + hlm.printHeapInfo(); + } + + +} diff --git a/src/main/java/kr/co/mantech/jungwon/BindQuery.java b/src/main/java/kr/co/mantech/jungwon/BindQuery.java new file mode 100644 index 0000000..776e647 --- /dev/null +++ b/src/main/java/kr/co/mantech/jungwon/BindQuery.java @@ -0,0 +1,139 @@ +package kr.co.mantech.jungwon; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Locale; + +import javax.servlet.http.HttpServletResponse; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; + +/** + * Handles requests for the application home page. + */ +@Controller +public class BindQuery extends Query +{ + /** + * Logger for this class + */ + private static final Logger logger = LoggerFactory.getLogger(BindQuery.class); + + public static final String queryName="BindQuery"; + public BindQuery() + { + // 쿼리 이름 셋팅 // + super(queryName); + + } + + + //init 호출 + @RequestMapping(value = "/query/"+queryName+"/init", method = {RequestMethod.GET, RequestMethod.POST}) + public String init( + Locale locale, Model model) + { + + initQuery(fileName,orgFileName); + model.addAttribute("query", fileQueryString); + model.addAttribute("queryName", queryName); + model.addAttribute("bindCount",0); + return "/query/"+queryName; + } + + //save 호출 + @RequestMapping(value = "/query/"+queryName+"/save", method = {RequestMethod.GET, RequestMethod.POST}) + public String save( + Locale locale, Model model, + @RequestParam(value="querytextarea", required=false) String querytextarea, + @RequestParam(value="save", required=false) String save) + { + saveQuery(querytextarea); + model.addAttribute("query", fileQueryString); + model.addAttribute("queryName", queryName); + return "/query/"+queryName; + } + + //기본화면 호출 + @RequestMapping(value = "/query/"+queryName, method = {RequestMethod.GET, RequestMethod.POST}) + public String gibon(Locale locale, Model model, HttpServletResponse response, + @RequestParam(value="init", required=false) String init, + @RequestParam(value="save", required=false) String save, + @RequestParam(value="excute", required=false) String excute, + @RequestParam(value="v_name", required=false) List v_name, // 바인드 변수 처리 + @RequestParam(value="v_value", required=false) List v_value, // 바인드 변수 처리 + @RequestParam(value="v_type", required=false) List v_type, // 바인드 변수 처리 + @RequestParam(value="dataSource", required=false) String dataSource) + { + + LinkedHashMap results=null; + + // Read Query + if(init==null & save==null & excute==null) + { + this.readQuery(); + } + + else if(excute!=null && excute.equals("excute")) + { + try + { + results = excuteQuery(this.queryString, dataSource,v_name, v_value,v_type); + model.addAttribute("queryResult", results.get("queryResult")); + model.addAttribute("resultCode", results.get("resultCode")); + } + catch(Exception e) + { + //에러 발생시 500으로 응답 + response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + // 에러에 대한 result를 에러를 셋팅하여 보내줌 + StringWriter sw= new StringWriter(); + e.printStackTrace(new PrintWriter(sw)); + model.addAttribute("queryResult",sw.toString()); + + } + + if(queryString.length()==0) + { + this.readQuery(); + } + + if (logger.isDebugEnabled() && results !=null) { + logger.debug("gibon(Locale, Model, String, String, String, String) - queryString={}, columnsName={}", queryString, columnsName); //$NON-NLS-1$ + + model.addAttribute("columnsName",columnsName); + model.addAttribute("etime", results.get("etime")); + } + } + model.addAttribute("query", fileQueryString); + model.addAttribute("queryName", queryName); + + if (logger.isDebugEnabled()) + { + logger.debug("gibon(Locale, Model, String, String, String, List, String) - values=" + v_value); //$NON-NLS-1$ + } + + if (v_name!=null && !v_name.isEmpty()) + { + model.addAttribute("bindCount",v_name.size()); + model.addAttribute("v_name",v_name); + model.addAttribute("v_type",v_type); + model.addAttribute("v_value",v_value); + } + else + { + model.addAttribute("bindCount",0); + } + + return "/query/"+queryName; + } +} diff --git a/src/main/java/kr/co/mantech/jungwon/DBManager.java b/src/main/java/kr/co/mantech/jungwon/DBManager.java new file mode 100644 index 0000000..5442271 --- /dev/null +++ b/src/main/java/kr/co/mantech/jungwon/DBManager.java @@ -0,0 +1,94 @@ +package kr.co.mantech.jungwon; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.sql.Connection; +import java.sql.SQLException; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import javax.sql.DataSource; +public class DBManager { + /** + * Logger for this class + */ + + private static final Logger logger = LoggerFactory.getLogger(DBManager.class); + + public static Connection getConnection() throws Exception + { + logger.debug("getConnection"); + return getConnection("datasource"); + + } + public static Connection getConnection(String dsName) throws Exception + { + Context initCtx = null; + Context envCtx = null; + Connection conn = null; + DataSource ds = null; + if (logger.isDebugEnabled()) { + logger.debug("getConnection(String) - {}", "========START GET CONNECTION ============="); //$NON-NLS-1$ //$NON-NLS-2$ + } + + try { initCtx = new InitialContext(); + if (logger.isDebugEnabled()) { + logger.debug("getConnection(String) - {}", dsName); //$NON-NLS-1$ + + } + + String was_type=System.getProperty("WAS_TYPE"); + logger.debug("getConnection(String) - WAS_TYPE{}", was_type); + if (was_type != null && was_type.equals("JEUS")) + { + //�냼�뒪 �닔�젙 (�젣�슦�뒪�씪�븣) + logger.debug("getConnection(String) - WAS_TYPE{} JEUS", was_type); + ds = (DataSource)initCtx.lookup(dsName); + } + else + { + logger.debug("getConnection(String) - WAS_TYPE{} OTHERS", was_type); + ds = (DataSource)initCtx.lookup("java:/comp/env/"+dsName); + } + + + conn = ds.getConnection(); + } catch (Exception ex) { + logger.error("getConnection(String)", ex); //$NON-NLS-1$ + + } finally { + try { + if (envCtx != null) { + envCtx.close(); + } + if (initCtx != null) + initCtx.close(); + } + catch (NamingException ex) { + logger.error("getConnection(String)", ex); //$NON-NLS-1$ + } + } + + if (logger.isDebugEnabled()) { + logger.debug("getConnection(String) - {}", "========END GET CONNECTION ============="); //$NON-NLS-1$ //$NON-NLS-2$ + } + return conn; + } + + public static void close(Connection con) throws Exception + { + if (logger.isDebugEnabled()) { + logger.debug("close(Connection) - {}", "========START CLOSE CONNECTION ============="); //$NON-NLS-1$ //$NON-NLS-2$ + } + if (logger.isDebugEnabled()) { + logger.debug("close(Connection) - {}", "con" + con); //$NON-NLS-1$ //$NON-NLS-2$ + } + if ( con != null ) try { con.close(); } catch(Exception e) {} + if (logger.isDebugEnabled()) { + logger.debug("close(Connection) - {}", "========END CLOSE CONNECTION ============="); //$NON-NLS-1$ //$NON-NLS-2$ + } + + } + +} diff --git a/src/main/java/kr/co/mantech/jungwon/F12/APMBMT2Class.java b/src/main/java/kr/co/mantech/jungwon/F12/APMBMT2Class.java new file mode 100644 index 0000000..6be27c6 --- /dev/null +++ b/src/main/java/kr/co/mantech/jungwon/F12/APMBMT2Class.java @@ -0,0 +1,25 @@ +package kr.co.mantech.jungwon.F12; + + +public class APMBMT2Class { + + public APMBMT2Class () + { + System.out.println("Contruction Init"); + } + + + public void printInfo(int second) throws Exception + { + System.out.println("==========================="); + System.out.println("Start"); + System.out.println("kr.or.tta.jungwon.F12.APMBMT2Class-printInfo"); + Thread.sleep(second*1000); + System.out.println("kr.or.tta.jungwon.F12.APMBMT2Class-printInfo: "+ second + " sec"); + System.out.println("End"); + System.out.println("==========================="); + + + } + +} diff --git a/src/main/java/kr/co/mantech/jungwon/F12/APMBMTClass.java b/src/main/java/kr/co/mantech/jungwon/F12/APMBMTClass.java new file mode 100644 index 0000000..4e8364e --- /dev/null +++ b/src/main/java/kr/co/mantech/jungwon/F12/APMBMTClass.java @@ -0,0 +1,62 @@ +package kr.co.mantech.jungwon.F12; + + +public class APMBMTClass { + + public APMBMTClass () + { + System.out.println("Contruction Init"); + } + + + public void printInfo(int second) throws Exception + { + System.out.println("==========================="); + System.out.println("Start"); + System.out.println("printInfo"); + Thread.sleep(second*1000); + System.out.println("printInfo: "+ second + " sec"); + System.out.println("End"); + System.out.println("==========================="); + + } + + public void printInfo1(int second) throws Exception + { + System.out.println("==========================="); + System.out.println("Start"); + System.out.println("printInfo-1"); + Thread.sleep(second*1000); + System.out.println("printInfo-1: "+ second + " sec"); + + printInfo2(second); + + System.out.println("End"); + System.out.println("==========================="); + + + + } + + public void printInfo2(int second) throws Exception + { + System.out.println("==========================="); + System.out.println("printInfo-2"); + Thread.sleep(second*1000); + System.out.println("printInfo-2: "+ second + " sec"); + System.out.println("==========================="); + } + public void printInfo3(int second) throws Exception + { + System.out.println("==========================="); + System.out.println("printInfo-3(check method cap time!!!)"); + Thread.sleep(second*1000); + + APMBMT2Class apm2 = new APMBMT2Class(); + apm2.printInfo(5); + + System.out.println("printInfo-3: "+ second + " sec"); + System.out.println("==========================="); + } + +} diff --git a/src/main/java/kr/co/mantech/jungwon/Query.java b/src/main/java/kr/co/mantech/jungwon/Query.java new file mode 100644 index 0000000..c1370ba --- /dev/null +++ b/src/main/java/kr/co/mantech/jungwon/Query.java @@ -0,0 +1,324 @@ +package kr.co.mantech.jungwon; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.math.BigDecimal; +import java.sql.Connection; +import java.sql.Date; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import javax.net.ssl.HandshakeCompletedListener; +import javax.servlet.ServletContext; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; + +public abstract class Query { + + private static final Logger logger = LoggerFactory.getLogger(Query.class); + + public static final String queryRepository = "/" + "resources"+File.separator+"query"; + + public StringBuffer fileQueryString = new StringBuffer(); + public StringBuffer queryString = new StringBuffer(); + + public String columnsName; + public String fileName ; + public String orgFileName; + public String orgFileName2; + + + ArrayList arrayOfBindName = new ArrayList(); + + @Autowired ServletContext servletContext; //servletConext �쓽議댁꽦 二쇱엯 + + // query�뙆�씪�쓣 �떎�떆 �씫怨� 珥덇린�솕 �븳�떎. + public Query(String queryName) + { + fileName = queryRepository+File.separator+queryName+".sql"; + orgFileName= queryRepository+File.separator+queryName+".org.sql"; + + logger.info("fileName={}", fileName); + logger.info("orgFileName={}", orgFileName); + + + } + public void initQuery(String fileName,String orgFileName) + { + + File ifile = new File(servletContext.getRealPath("/")+orgFileName); + File ofile = new File(servletContext.getRealPath("/")+fileName); + if (logger.isDebugEnabled()) { + logger.debug("init() - {}", ofile); //$NON-NLS-1$ + } + try { + FileOutputStream fo = new FileOutputStream(ofile); + FileInputStream fi = new FileInputStream(ifile); + + int data = 0; + while ((data = fi.read()) != -1) { + fo.write(data); + } + fo.close(); + fi.close(); + + this.readQuery(); + + } catch (FileNotFoundException e) { + logger.error("init()", e); + } catch (IOException e) { + logger.error("init()", e); + } + } + + public synchronized void readQuery() // queryString �룞湲고솕 + { + fileQueryString.setLength(0); + queryString.setLength(0); + InputStream is = servletContext.getResourceAsStream(fileName); + InputStreamReader isr = new InputStreamReader(is); + BufferedReader br = new BufferedReader(isr); + String s; + try { + while ((s=br.readLine())!=null) + { + fileQueryString.append(s); + //fileQueryString.append(System.lineSeparator()); + fileQueryString.append(System.getProperty("line.separator")); + + } + + } catch (IOException e) { + e.printStackTrace(); + } + + if (logger.isDebugEnabled()) { + logger.info("readQuery() - String fileQueryString={}", queryString); //$NON-NLS-1$ + } + // �뙆�씪�쓣 �씪怨� �뙣�꽩�쑝濡� �뙆�씪誘명꽣瑜� 鍮쇱삤怨�, ? �쑝濡� 臾몄옄瑜� 援먯껜�븳�떎. + this.parseQuery(); + } + public synchronized void parseQuery() // queryString �룞湲고솕 + { + //Pattern pattern = Pattern.compile("#[a-zA-Z_0-9]*#"); + String s_pattern=":[a-zA-Z_0-9]*"; + Pattern pattern = Pattern.compile(s_pattern); + Matcher matcher = pattern.matcher(fileQueryString.toString()); + + //arrayOfString 珥덇린�솕 + arrayOfBindName.clear(); + + //諛붿씤�뱶 蹂��닔 �꽔湲�// + while (matcher.find()) + { + arrayOfBindName.add(matcher.group()); + } + //諛붿씤�뱶 蹂��닔�뿉 ? �쑝濡� 援먯껜 + queryString.append(matcher.replaceAll("?")); + + } + + public void setStringAsName(String name, String value, String type, PreparedStatement ps) throws SQLException + { + String [] arrayString= arrayOfBindName.toArray(new String[]{}); + + logger.debug("setStringAsName(String, String, String, PreparedStatement) - String[] arrayString=" + arrayOfBindName); //$NON-NLS-1$ + for(int i=0; i excuteQuery(StringBuffer sql,String dataSource,List names , List values, List type ) throws Exception + { + + ResultSet rs=null; + Connection con=null; + PreparedStatement ps=null; + // ArrayList results = new ArrayList(); + LinkedHashMap results = new LinkedHashMap(); + + long begin=0; + long end=0; + + + try + { + + logger.debug("excuteQuery(DataSource) - {}", dataSource); //$NON-NLS-1$ + logger.debug("excuteQuery(sql) - {}", sql); //$NON-NLS-1$ + logger.debug("excuteQuery(values) - {}", values); //$NON-NLS-1$ + logger.debug("excuteQuery(type) - {}", type); //$NON-NLS-1$ + + con=DBManager.getConnection(dataSource); + ps = con.prepareStatement(sql.toString()); + + + + if (values!=null && !values.isEmpty()) + { + for (int i=0;i>>>>>>>> QUERY TIME - {} ms <<<<<<<<<<<" , etime); + results.put("etime", etime +"(ms)"); + + } + + if (logger.isInfoEnabled()) { + logger.info("excuteQuery(StringBuffer, String) - Success"); //$NON-NLS-1$ + results.put("resultCode", "Success"); + + } + + } + catch ( Exception e ) + { + logger.error("excuteQuery(StringBuffer, String)", e); + // �뿉�윭�뿉 ���븳 result瑜� �뿉�윭瑜� �뀑�똿�븯�뿬 蹂대궡以� + throw new Exception(e); + + } + finally + { + if ( rs != null ) try { rs.close();} catch(Exception e){} + if ( ps != null ) try { ps.close(); } catch(Exception e) {} + if ( con != null ) try { con.close(); } catch(Exception e) {} + } + return results; + } + + +} diff --git a/src/main/java/kr/co/mantech/jungwon/Query1.java b/src/main/java/kr/co/mantech/jungwon/Query1.java new file mode 100644 index 0000000..92bca55 --- /dev/null +++ b/src/main/java/kr/co/mantech/jungwon/Query1.java @@ -0,0 +1,139 @@ +package kr.co.mantech.jungwon; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Locale; + +import javax.servlet.http.HttpServletResponse; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; + +/** + * Handles requests for the application home page. + */ +@Controller +public class Query1 extends Query +{ + /** + * Logger for this class + */ + private static final Logger logger = LoggerFactory.getLogger(Query1.class); + + public static final String queryName="Query1"; + public Query1() + { + // 荑쇰━ �씠由� �뀑�똿 // + super(queryName); + + } + + + //init �샇異� + @RequestMapping(value = "/query/"+queryName+"/init", method = {RequestMethod.GET, RequestMethod.POST}) + public String init( + Locale locale, Model model) + { + + initQuery(fileName,orgFileName); + model.addAttribute("query", fileQueryString); + model.addAttribute("queryName", queryName); + model.addAttribute("bindCount",0); + return "/query/"+queryName; + } + + //save �샇異� + @RequestMapping(value = "/query/"+queryName+"/save", method = {RequestMethod.GET, RequestMethod.POST}) + public String save( + Locale locale, Model model, + @RequestParam(value="querytextarea", required=false) String querytextarea, + @RequestParam(value="save", required=false) String save) + { + saveQuery(querytextarea); + model.addAttribute("query", fileQueryString); + model.addAttribute("queryName", queryName); + return "/query/"+queryName; + } + + //湲곕낯�솕硫� �샇異� + @RequestMapping(value = "/query/"+queryName, method = {RequestMethod.GET, RequestMethod.POST}) + public String gibon(Locale locale, Model model, HttpServletResponse response, + @RequestParam(value="init", required=false) String init, + @RequestParam(value="save", required=false) String save, + @RequestParam(value="excute", required=false) String excute, + @RequestParam(value="v_name", required=false) List v_name, // 諛붿씤�뱶 蹂��닔 泥섎━ + @RequestParam(value="v_value", required=false) List v_value, // 諛붿씤�뱶 蹂��닔 泥섎━ + @RequestParam(value="v_type", required=false) List v_type, // 諛붿씤�뱶 蹂��닔 泥섎━ + @RequestParam(value="dataSource", required=false) String dataSource) + { + + LinkedHashMap results=null; + + // Read Query + if(init==null & save==null & excute==null) + { + this.readQuery(); + } + + else if(excute!=null && excute.equals("excute")) + { + try + { + results = excuteQuery(this.queryString, dataSource,v_name, v_value,v_type); + model.addAttribute("queryResult", results.get("queryResult")); + model.addAttribute("resultCode", results.get("resultCode")); + } + catch(Exception e) + { + //�뿉�윭 諛쒖깮�떆 500�쑝濡� �쓳�떟 + response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + // �뿉�윭�뿉 ���븳 result瑜� �뿉�윭瑜� �뀑�똿�븯�뿬 蹂대궡以� + StringWriter sw= new StringWriter(); + e.printStackTrace(new PrintWriter(sw)); + model.addAttribute("queryResult",sw.toString()); + + } + + if(queryString.length()==0) + { + this.readQuery(); + } + + if (logger.isDebugEnabled() && results !=null) { + logger.debug("gibon(Locale, Model, String, String, String, String) - queryString={}, columnsName={}", queryString, columnsName); //$NON-NLS-1$ + + model.addAttribute("columnsName",columnsName); + model.addAttribute("etime", results.get("etime")); + } + } + model.addAttribute("query", fileQueryString); + model.addAttribute("queryName", queryName); + + if (logger.isDebugEnabled()) + { + logger.debug("gibon(Locale, Model, String, String, String, List, String) - values=" + v_value); //$NON-NLS-1$ + } + + if (v_name!=null && !v_name.isEmpty()) + { + model.addAttribute("bindCount",v_name.size()); + model.addAttribute("v_name",v_name); + model.addAttribute("v_type",v_type); + model.addAttribute("v_value",v_value); + } + else + { + model.addAttribute("bindCount",0); + } + + return "/query/"+queryName; + } +} diff --git a/src/main/java/kr/co/mantech/jungwon/Root.java b/src/main/java/kr/co/mantech/jungwon/Root.java new file mode 100644 index 0000000..510c368 --- /dev/null +++ b/src/main/java/kr/co/mantech/jungwon/Root.java @@ -0,0 +1,106 @@ +package kr.co.mantech.jungwon; + +import java.text.DateFormat; +import java.util.Date; +import java.util.Locale; +import java.util.concurrent.ThreadLocalRandom; +import java.io.*; +import javax.naming.*; +import java.sql.*; +import javax.sql.*; + + +import javax.servlet.ServletContext; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; + +/** + * Handles requests for the application home page. + */ +@Controller +public class Root { + + private static final Logger logger = LoggerFactory.getLogger(Root.class); + + /** + * Simply selects the home view to render by returning its name. + */ + @RequestMapping(value = "/", method = RequestMethod.GET) + public String home(Locale locale, Model model) { + + Date date = new Date(); + DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale); + + String formattedDate = dateFormat.format(date); + //String stringFormat = "Start"; + + model.addAttribute("serverTime", formattedDate ); + + return "root"; + } + @RequestMapping(value = "/jsp/session-info", method = RequestMethod.GET) + public String sessioninfo(Locale locale, Model model) { + + + return "/jsp/session-info"; + } + + @RequestMapping(value = "/jsp/sleep", method = RequestMethod.GET) + public String sleep(Locale locale, Model model, + @RequestParam(value="second", required=false) String second) + { + + if (second == null ) + { + second="1"; + } + long start = System.currentTimeMillis(); + try { + Thread.sleep(Integer.parseInt(second)*1000); + } catch (NumberFormatException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + int cnt=0; + int count=5; + while (true) + { + + // double a=Math.random(); + // double b=Math.random(); + double a=ThreadLocalRandom.current().nextDouble(); + double b=ThreadLocalRandom.current().nextDouble(); + + System.out.println(a); + System.out.println(b); + double c=a*b*a; + + if (cnt==count) + break; + cnt++; + } + + long end = System.currentTimeMillis(); + long gap = (end-start); + + model.addAttribute("second", second ); + model.addAttribute("gap", gap ); + + return "/jsp/sleep"; + } + + + + +} diff --git a/src/main/resources/log4j.xml b/src/main/resources/log4j.xml new file mode 100644 index 0000000..a3b1360 --- /dev/null +++ b/src/main/resources/log4j.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/META-INF/MANIFEST.MF b/src/main/webapp/META-INF/MANIFEST.MF new file mode 100644 index 0000000..58630c0 --- /dev/null +++ b/src/main/webapp/META-INF/MANIFEST.MF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 + diff --git a/src/main/webapp/WEB-INF/jboss-web.xml b/src/main/webapp/WEB-INF/jboss-web.xml new file mode 100644 index 0000000..8c3bc4a --- /dev/null +++ b/src/main/webapp/WEB-INF/jboss-web.xml @@ -0,0 +1,6 @@ + + + SET + SESSION + + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/lib/javassist-3.0.jar b/src/main/webapp/WEB-INF/lib/javassist-3.0.jar new file mode 100644 index 0000000..57bbf97 Binary files /dev/null and b/src/main/webapp/WEB-INF/lib/javassist-3.0.jar differ diff --git a/src/main/webapp/WEB-INF/lib/mysql-connector-java-5.1.31.jar b/src/main/webapp/WEB-INF/lib/mysql-connector-java-5.1.31.jar new file mode 100644 index 0000000..26864e4 Binary files /dev/null and b/src/main/webapp/WEB-INF/lib/mysql-connector-java-5.1.31.jar differ diff --git a/src/main/webapp/WEB-INF/lib/ojdbc6.jar b/src/main/webapp/WEB-INF/lib/ojdbc6.jar new file mode 100644 index 0000000..fb50fb9 Binary files /dev/null and b/src/main/webapp/WEB-INF/lib/ojdbc6.jar differ diff --git a/src/main/webapp/WEB-INF/lib/taglibs-standard-impl-1.2.3.jar b/src/main/webapp/WEB-INF/lib/taglibs-standard-impl-1.2.3.jar new file mode 100644 index 0000000..1b3add5 Binary files /dev/null and b/src/main/webapp/WEB-INF/lib/taglibs-standard-impl-1.2.3.jar differ diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..99f7745 --- /dev/null +++ b/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,13 @@ + + + WEBAPP + + index.html + index.htm + index.jsp + default.html + default.htm + default.jsp + + + \ No newline at end of file diff --git a/src/main/webapp/css/template.css b/src/main/webapp/css/template.css new file mode 100644 index 0000000..58a5cc3 --- /dev/null +++ b/src/main/webapp/css/template.css @@ -0,0 +1,39 @@ +html +{ + height: 100%; + width: 100%; +} +body +{ + height: 100%; + width: 100%; +} +h1,h2,h3,h4 +{ + margin: auto; +} +#left +{ + float: left; + padding: 10px; + +} +#contents +{ + border-left:3px solid gray; + float: left; + padding: 20px; + height: 100%; + width: 60%; + overflow: scroll; +} +#middle +{ + height: 70%; + width: 100%; +} +#footer +{ + clear: both; + padding: 10px; +} diff --git a/src/main/webapp/html/error.html b/src/main/webapp/html/error.html new file mode 100644 index 0000000..f2b9699 --- /dev/null +++ b/src/main/webapp/html/error.html @@ -0,0 +1,25 @@ + + + + +Insert title here + + + + + + + + + + + +
TTA logo
BMT logo + +
+ + +

Ͽ ߴԴϴ. !!

+ +Copyright 2017 TTA All Rights Reserved (TTA ѱűȸ)

+ \ No newline at end of file diff --git a/src/main/webapp/html/re.html b/src/main/webapp/html/re.html new file mode 100644 index 0000000..057dc32 --- /dev/null +++ b/src/main/webapp/html/re.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp new file mode 100644 index 0000000..a07293a --- /dev/null +++ b/src/main/webapp/index.jsp @@ -0,0 +1,9 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> + + + + + + \ No newline at end of file diff --git a/src/main/webapp/jsp/F01-image.jsp b/src/main/webapp/jsp/F01-image.jsp new file mode 100644 index 0000000..151ed53 --- /dev/null +++ b/src/main/webapp/jsp/F01-image.jsp @@ -0,0 +1,39 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + + + + +Insert title here + + +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> +
    + + + +

    APM BMT !!

    +

    + 샘플 1
    + +

    + +

    + 샘플 2
    + +

    + + +

    + 샘플 3
    + +

    + + + +
    + + + + + \ No newline at end of file diff --git a/src/main/webapp/jsp/OOMTest.jsp b/src/main/webapp/jsp/OOMTest.jsp new file mode 100644 index 0000000..b444d71 --- /dev/null +++ b/src/main/webapp/jsp/OOMTest.jsp @@ -0,0 +1,46 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ page import = "java.util.*" %> +<%@ page import = "kr.co.mantech.common.*" %> + + + + +Insert title here + + +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> +
      + + + +

      OOM BMT !!

      + +<%! +HeapLeakManager hlm = new HeapLeakManager(false,50000, HeapLeakManager.CheckType.Heap); + +%> + <% + + HashMap hm= hlm.doLeak(); + + +%> +
      +HeapSize =<%= hm.get("heapSize") %> MB +
      +freeHeapSize =<%= hm.get("freeHeapSize") %> MB +
      +ArraySize =<%= hm.get("ArraySize") %> 개 +
      +Number of Loaded Class =<%= hm.get("classesSize") %> 개 +
      + +

      + +
      + + + + + \ No newline at end of file diff --git a/src/main/webapp/jsp/PermOOM.jsp b/src/main/webapp/jsp/PermOOM.jsp new file mode 100644 index 0000000..c9b8a7e --- /dev/null +++ b/src/main/webapp/jsp/PermOOM.jsp @@ -0,0 +1,48 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ page import = "java.util.*" %> +<%@ page import = "kr.co.mantech.common.*" %> + + + + + +Insert title here + + +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> +
        + + + +

        Perm OOM BMT !!

        + +<%! +HeapLeakManager hlm = new HeapLeakManager(true,10000, HeapLeakManager.CheckType.Perm); + +%> + <% + + HashMap hm= hlm.doLeak(); + + +%> +
        +HeapSize =<%= hm.get("heapSize") %> MB +
        +freeHeapSize =<%= hm.get("freeHeapSize") %> MB +
        +ArraySize =<%= hm.get("ArraySize") %> 개 +
        +Number of Loaded Class =<%= hm.get("classesSize") %> 개 +
        + + +

        + +
        + + + + + \ No newline at end of file diff --git a/src/main/webapp/jsp/classMethod.jsp b/src/main/webapp/jsp/classMethod.jsp new file mode 100644 index 0000000..d136687 --- /dev/null +++ b/src/main/webapp/jsp/classMethod.jsp @@ -0,0 +1,40 @@ +<%@page import="java.util.Calendar"%> +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ page import="java.util.Date" %> +<%@ page import="kr.co.mantech.jungwon.F12.*" %> + + + + +Insert title here + + +<% + +APMBMTClass apm = new APMBMTClass(); +out.println("APMBMTClass + printInfo + 1 second"); +out.println("
        "); +apm.printInfo(1); + +out.println("APMBMTClass + printInfo + 5 second"); +apm.printInfo(5); +out.println("
        "); + +out.println("APMBMTClass + printInfo + 10 second"); +apm.printInfo(10); +out.println("
        "); + + +out.println("APMBMTClass + printInfo-nested"); +apm.printInfo1(1); +out.println("
        "); + +out.println("APMBMTClass + printInfo + Check Method Cap Time "); +apm.printInfo3(1); +out.println("
        "); + +%> + + + \ No newline at end of file diff --git a/src/main/webapp/jsp/common/footer.jsp b/src/main/webapp/jsp/common/footer.jsp new file mode 100644 index 0000000..f46e745 --- /dev/null +++ b/src/main/webapp/jsp/common/footer.jsp @@ -0,0 +1,5 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + +
        +Copyright 2020 (주)맨텍 All Rights Reserved

        \ No newline at end of file diff --git a/src/main/webapp/jsp/common/header.jsp b/src/main/webapp/jsp/common/header.jsp new file mode 100644 index 0000000..a1eb527 --- /dev/null +++ b/src/main/webapp/jsp/common/header.jsp @@ -0,0 +1,18 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> + + + + + + + + + + + +
        Mantech logo
        accordion logo

        샘플 테스트 WEBAPP Version 1

        +
        +
        \ No newline at end of file diff --git a/src/main/webapp/jsp/common/menu.jsp b/src/main/webapp/jsp/common/menu.jsp new file mode 100644 index 0000000..f8aa5b0 --- /dev/null +++ b/src/main/webapp/jsp/common/menu.jsp @@ -0,0 +1,56 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> + \ No newline at end of file diff --git a/src/main/webapp/jsp/common/sleep.jsp b/src/main/webapp/jsp/common/sleep.jsp new file mode 100644 index 0000000..d0a87bb --- /dev/null +++ b/src/main/webapp/jsp/common/sleep.jsp @@ -0,0 +1,52 @@ +<%@page import="java.util.Calendar"%> +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ page import="java.util.Date" %> + + + + +Insert title here + +<% + +String second = request.getParameter("second"); +if (second == null ) +{ + second="1"; +} + + +%> + + + + + + + + + + +
        TTA logo
        BMT logo

        Sleep for ${second} second

        + + +
        + +
        + + + +<% +long start = System.currentTimeMillis(); +Thread.sleep(Integer.parseInt(second)*1000); +long end = System.currentTimeMillis(); +long gap = (end-start); +%> + +

        Call Success !!!!!


        +

        elapsed time = <%= gap %> ms


        +
        +Copyright 2017 TTA All Rights Reserved (TTA 한국정보통신기술협회)

        + + \ No newline at end of file diff --git a/src/main/webapp/jsp/common/template.jsp b/src/main/webapp/jsp/common/template.jsp new file mode 100644 index 0000000..e9a40cb --- /dev/null +++ b/src/main/webapp/jsp/common/template.jsp @@ -0,0 +1,38 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> + + + + + + + +${param.title} + + + + + +
        +

        TEST CASE

        + +
        + +
        + +
        + +
        + + + + + + + \ No newline at end of file diff --git a/src/main/webapp/jsp/cpu.jsp b/src/main/webapp/jsp/cpu.jsp new file mode 100644 index 0000000..812ee22 --- /dev/null +++ b/src/main/webapp/jsp/cpu.jsp @@ -0,0 +1,38 @@ +<%@page import="java.util.Calendar"%> +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ page import="java.util.Date" %> + + + + +Insert title here + + +<% + + +while (true) +{ + int time=0; + + for (int i=1; i<100000;i++) + { + double temp = Math.random()* Math.random() * 100; + String str = "aaa"; + str = str+str; + + } + +Thread.sleep(100); + +time++; +if (time==200) +break; +} + + +%> + + + \ No newline at end of file diff --git a/src/main/webapp/jsp/db-connection-info.jsp b/src/main/webapp/jsp/db-connection-info.jsp new file mode 100644 index 0000000..b7445fa --- /dev/null +++ b/src/main/webapp/jsp/db-connection-info.jsp @@ -0,0 +1,89 @@ + +<%@ page language="java" contentType="text/html;charset=EUC-KR"%> +<%@ page import="kr.co.mantech.common.DBManager" %> +<%@ page import="java.sql.*" %> + +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> + + + + +XA_DataSource Test + + + +<% +String sql = request.getParameter("sql"); +if (sql==null) + sql="select * from emp"; +String dsName = request.getParameter("dsName"); +%> + + + + +<% +ResultSet rs=null; +Connection con=null; +PreparedStatement ps = null; +DBManager db; +db = new DBManager(); +%> + +

        +
        + +

        JNDI NAME <%=dsName%>
        selectSQL <%=sql%>
        DESC Select from <%=dsName%>
        + + + + + + + + + + +
        DataSource JNDI
        SQL
        + + +<% +if (dsName !=null ) +{ + con = db.getConnection(dsName); + ps = con.prepareStatement(sql); + rs = db.selectSQL(ps); + ResultSetMetaData rsmd = rs.getMetaData(); + int columnCnt = rsmd.getColumnCount() ; + out.print("
        "); + out.print("

        Sql Query = " + sql + "

        "); + out.print(""); + for(int i=1;i<=columnCnt;i++) + { + out.print(""); + } + out.print(""); + + while(rs.next()) + { + out.print(""); + for(int i=1;i<=columnCnt;i++) + { + + out.print(""); + } + out.print(""); + } + out.print("
        "); + out.print(rsmd.getColumnName(i)); + out.print("
        "); + out.print(rs.getString(i)); + out.print("
        "); + + db.close(con, rs, ps); +} + +%> + + + diff --git a/src/main/webapp/jsp/db-connection-leak.jsp b/src/main/webapp/jsp/db-connection-leak.jsp new file mode 100644 index 0000000..5bd37dc --- /dev/null +++ b/src/main/webapp/jsp/db-connection-leak.jsp @@ -0,0 +1,89 @@ + +<%@ page language="java" contentType="text/html;charset=EUC-KR"%> +<%@ page import="kr.co.mantech.common.DBManager" %> +<%@ page import="java.sql.*" %> + +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> + + + + +Conncecion Leak + + + +<% +String sql = request.getParameter("sql"); +if (sql==null) + sql="select * from emp"; +String dsName = request.getParameter("dsName"); +%> + + + + +<% +ResultSet rs=null; +Connection con=null; +PreparedStatement ps = null; +DBManager db; +db = new DBManager(); +%> + +

        +
        + +

        JNDI NAME <%=dsName%>
        selectSQL <%=sql%>
        DESC Select from <%=dsName%>
        + + + + + + + + + + +
        DataSource JNDI
        SQL
        + + +<% +if (dsName !=null ) +{ + con = db.getConnection(dsName); + ps = con.prepareStatement(sql); + rs = db.selectSQL(ps); + ResultSetMetaData rsmd = rs.getMetaData(); + int columnCnt = rsmd.getColumnCount() ; + out.print("
        "); + out.print("

        Sql Query = " + sql + "

        "); + out.print(""); + for(int i=1;i<=columnCnt;i++) + { + out.print(""); + } + out.print(""); + + while(rs.next()) + { + out.print(""); + for(int i=1;i<=columnCnt;i++) + { + + out.print(""); + } + out.print(""); + } + out.print("
        "); + out.print(rsmd.getColumnName(i)); + out.print("
        "); + out.print(rs.getString(i)); + out.print("
        "); + + //db.close(con, rs, ps); +} + +%> + + + diff --git a/src/main/webapp/jsp/normal.jsp b/src/main/webapp/jsp/normal.jsp new file mode 100644 index 0000000..d6aa434 --- /dev/null +++ b/src/main/webapp/jsp/normal.jsp @@ -0,0 +1,16 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + + + + +Insert title here + + + + +

        APM BMT !!

        + + + + \ No newline at end of file diff --git a/src/main/webapp/jsp/readme.jsp b/src/main/webapp/jsp/readme.jsp new file mode 100644 index 0000000..2791a38 --- /dev/null +++ b/src/main/webapp/jsp/readme.jsp @@ -0,0 +1,28 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + +

        +APM BMT 테스트 +

        + +1) 기본 페이지
        + http://IP/NIA-APM-BMT/jsp/common/normal.jsp
        + + + +2) F01 : 클라이언트 분리 호출(이미지/JSP)
        + +3) F02, F03 등 : HeapDump 생성 : 메모리 관련 모니터링(OutOfMemory)
        + +4) F06 : DB Connection 관련
        + +5) 응답지연 관련 : sleep.jsp
        + +6) cpu 관련 : cpu.jsp
        + + + + + + + \ No newline at end of file diff --git a/src/main/webapp/jsp/sample.jsp b/src/main/webapp/jsp/sample.jsp new file mode 100644 index 0000000..0560254 --- /dev/null +++ b/src/main/webapp/jsp/sample.jsp @@ -0,0 +1,28 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + + + + +Insert title here + + + + + + + + + + + +
        TTA logo
        BMT logo + +
        + + +

        Sample WAS BMT !!

        + +Copyright 2017 TTA All Rights Reserved (TTA 한국정보통신기술협회)

        + + \ No newline at end of file diff --git a/src/main/webapp/jsp/session-info.jsp b/src/main/webapp/jsp/session-info.jsp new file mode 100644 index 0000000..b420153 --- /dev/null +++ b/src/main/webapp/jsp/session-info.jsp @@ -0,0 +1,69 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + +<%@page import="java.util.*" %> +<%@page import="java.text.*" %> + + + + + +Insert title here + +<% +HttpSession sess = request.getSession(); +boolean isNew = session.isNew(); + String sessionId = session.getId(); + long creationTime = session.getCreationTime(); + long lastAccessedTime = session.getLastAccessedTime(); + int maxInactiveInterval = session.getMaxInactiveInterval(); + int rand_M=(int)(Math.random()*10000); + int rand_MS=(int)(Math.random()*10000); + + +if (sess.getAttribute("SessionAttr") ==null) { + out.println("

        session out

        "); +sess.setAttribute("SessionAttr", rand_M+""); +sess.setAttribute("SessionAttr2", rand_MS+""); +} else { + + + out.println("

        session exist

        "); + +} + + +java.util.Enumeration e = sess.getAttributeNames(); +%> + + + + + + + + + + + + + + + + + + + + + + +<% +String name = null; +while ( e.hasMoreElements() ) { +name = (String) e.nextElement(); +%> +

        +<% +} +%> +
        Session Info
        Session ID<%=sessionId%>
        isNewe<%=isNew%>
        Creation Time<%=new Date(creationTime)%>
        Last Accessed Time<%=new Date(lastAccessedTime)%>
        Max Inactive Interval<%=maxInactiveInterval%>
        Session Vaule List
        NAMEVAULE
        sessnion name <%=name%> <%=sess.getAttribute(name)%>
        diff --git a/src/main/webapp/jsp/sleep.jsp b/src/main/webapp/jsp/sleep.jsp new file mode 100644 index 0000000..d71f8da --- /dev/null +++ b/src/main/webapp/jsp/sleep.jsp @@ -0,0 +1,75 @@ +<%@page import="java.util.Calendar"%> +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ page import="java.util.Date" %> +<%@ page import="java.util.concurrent.*" %> + + + + +Insert title here + +<% + +String second = request.getParameter("second"); +if (second == null ) +{ + second="1"; +} + + +%> + + + + + + + + + + +
        TTA logo
        BMT logo

        Sleep for ${second} second

        + + +
        + +
        + + + +<% +long start = System.currentTimeMillis(); +Thread.sleep(Integer.parseInt(second)*1000); + +int cnt=0; +int count=5; +while (true) +{ + + // double a=Math.random(); + // double b=Math.random(); + double a=ThreadLocalRandom.current().nextDouble(); + double b=ThreadLocalRandom.current().nextDouble(); + + System.out.println(a); + System.out.println(b); + double c=a*b*a; + + if (cnt==count) + break; + cnt++; +} + +long end = System.currentTimeMillis(); +long gap = (end-start); + + +%> + +

        Call Success !!!!!


        +

        elapsed time = <%= gap %> ms


        +
        +Copyright 2017 TTA All Rights Reserved (TTA 한국정보통신기술협회)

        + + \ No newline at end of file diff --git a/src/main/webapp/jsp/sleep2.jsp b/src/main/webapp/jsp/sleep2.jsp new file mode 100644 index 0000000..883aa73 --- /dev/null +++ b/src/main/webapp/jsp/sleep2.jsp @@ -0,0 +1,55 @@ +<%@page import="java.util.Calendar"%> +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ page import="java.util.Date" %> +<%@ page import="java.util.concurrent.*" %> + + + + +Insert title here + +<% + +String second = request.getParameter("second"); +if (second == null ) +{ + second="1"; +} + + +%> + +<% +long start = System.currentTimeMillis(); +Thread.sleep(Integer.parseInt(second)*1000); + +int cnt=0; +int count=5; +while (true) +{ + + // double a=Math.random(); + // double b=Math.random(); + double a=ThreadLocalRandom.current().nextDouble(); + double b=ThreadLocalRandom.current().nextDouble(); + + System.out.println(a); + System.out.println(b); + double c=a*b*a; + + if (cnt==count) + break; + cnt++; +} + +long end = System.currentTimeMillis(); +long gap = (end-start); + + +%> + +

        Call Success !!!!!


        +

        elapsed time = <%= gap %> ms


        + + \ No newline at end of file diff --git a/src/main/webapp/jsp/thread-sleep.jsp b/src/main/webapp/jsp/thread-sleep.jsp new file mode 100644 index 0000000..d61875d --- /dev/null +++ b/src/main/webapp/jsp/thread-sleep.jsp @@ -0,0 +1,16 @@ +<%@page import="java.util.Calendar"%> +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ page import="java.util.Date" %> + + + + +Insert title here + + + + + + + \ No newline at end of file diff --git a/src/main/webapp/pages/F01-image.jsp b/src/main/webapp/pages/F01-image.jsp new file mode 100644 index 0000000..7d59f71 --- /dev/null +++ b/src/main/webapp/pages/F01-image.jsp @@ -0,0 +1,9 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> + + + + + + \ No newline at end of file diff --git a/src/main/webapp/pages/OOMTest.jsp b/src/main/webapp/pages/OOMTest.jsp new file mode 100644 index 0000000..3727f84 --- /dev/null +++ b/src/main/webapp/pages/OOMTest.jsp @@ -0,0 +1,9 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> + + + + + + \ No newline at end of file diff --git a/src/main/webapp/pages/PermOOM.jsp b/src/main/webapp/pages/PermOOM.jsp new file mode 100644 index 0000000..c2eb01c --- /dev/null +++ b/src/main/webapp/pages/PermOOM.jsp @@ -0,0 +1,9 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> + + + + + + \ No newline at end of file diff --git a/src/main/webapp/pages/classMethod.jsp b/src/main/webapp/pages/classMethod.jsp new file mode 100644 index 0000000..c95accc --- /dev/null +++ b/src/main/webapp/pages/classMethod.jsp @@ -0,0 +1,9 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> + + + + + + \ No newline at end of file diff --git a/src/main/webapp/pages/cpu.jsp b/src/main/webapp/pages/cpu.jsp new file mode 100644 index 0000000..a5d04fa --- /dev/null +++ b/src/main/webapp/pages/cpu.jsp @@ -0,0 +1,9 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> + + + + + + \ No newline at end of file diff --git a/src/main/webapp/pages/db-connection-info.jsp b/src/main/webapp/pages/db-connection-info.jsp new file mode 100644 index 0000000..d9c4e81 --- /dev/null +++ b/src/main/webapp/pages/db-connection-info.jsp @@ -0,0 +1,9 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> + + + + + + \ No newline at end of file diff --git a/src/main/webapp/pages/db-connection-leak.jsp b/src/main/webapp/pages/db-connection-leak.jsp new file mode 100644 index 0000000..c91167f --- /dev/null +++ b/src/main/webapp/pages/db-connection-leak.jsp @@ -0,0 +1,9 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> + + + + + + \ No newline at end of file diff --git a/src/main/webapp/pages/session-info.jsp b/src/main/webapp/pages/session-info.jsp new file mode 100644 index 0000000..72eaaf3 --- /dev/null +++ b/src/main/webapp/pages/session-info.jsp @@ -0,0 +1,9 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> + + + + + + \ No newline at end of file diff --git a/src/main/webapp/pages/thread-sleep-1.jsp b/src/main/webapp/pages/thread-sleep-1.jsp new file mode 100644 index 0000000..59e57c4 --- /dev/null +++ b/src/main/webapp/pages/thread-sleep-1.jsp @@ -0,0 +1,9 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> + + + + + + \ No newline at end of file diff --git a/src/main/webapp/pages/thread-sleep-3.jsp b/src/main/webapp/pages/thread-sleep-3.jsp new file mode 100644 index 0000000..a8cf69e --- /dev/null +++ b/src/main/webapp/pages/thread-sleep-3.jsp @@ -0,0 +1,9 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> + + + + + + \ No newline at end of file diff --git a/src/main/webapp/pages/thread-sleep.jsp b/src/main/webapp/pages/thread-sleep.jsp new file mode 100644 index 0000000..72e547e --- /dev/null +++ b/src/main/webapp/pages/thread-sleep.jsp @@ -0,0 +1,9 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> + + + + + + \ No newline at end of file diff --git a/src/main/webapp/resources/images/accordion_img.png b/src/main/webapp/resources/images/accordion_img.png new file mode 100644 index 0000000..01df430 Binary files /dev/null and b/src/main/webapp/resources/images/accordion_img.png differ diff --git a/src/main/webapp/resources/images/bmt_logo.gif b/src/main/webapp/resources/images/bmt_logo.gif new file mode 100644 index 0000000..8073994 Binary files /dev/null and b/src/main/webapp/resources/images/bmt_logo.gif differ diff --git a/src/main/webapp/resources/images/dummy-100x100-1.jpg b/src/main/webapp/resources/images/dummy-100x100-1.jpg new file mode 100644 index 0000000..1ddfa62 Binary files /dev/null and b/src/main/webapp/resources/images/dummy-100x100-1.jpg differ diff --git a/src/main/webapp/resources/images/dummy-100x100-2.jpg b/src/main/webapp/resources/images/dummy-100x100-2.jpg new file mode 100644 index 0000000..2b7fcb6 Binary files /dev/null and b/src/main/webapp/resources/images/dummy-100x100-2.jpg differ diff --git a/src/main/webapp/resources/images/dummy-100x100-3.jpg b/src/main/webapp/resources/images/dummy-100x100-3.jpg new file mode 100644 index 0000000..5a1e568 Binary files /dev/null and b/src/main/webapp/resources/images/dummy-100x100-3.jpg differ diff --git a/src/main/webapp/resources/images/dummy-100x100-4.jpg b/src/main/webapp/resources/images/dummy-100x100-4.jpg new file mode 100644 index 0000000..e57bec2 Binary files /dev/null and b/src/main/webapp/resources/images/dummy-100x100-4.jpg differ diff --git a/src/main/webapp/resources/images/mantech.png b/src/main/webapp/resources/images/mantech.png new file mode 100644 index 0000000..b64679e Binary files /dev/null and b/src/main/webapp/resources/images/mantech.png differ diff --git a/src/main/webapp/resources/images/tta_logo.png b/src/main/webapp/resources/images/tta_logo.png new file mode 100644 index 0000000..b92b55d Binary files /dev/null and b/src/main/webapp/resources/images/tta_logo.png differ