본문 바로가기

WAS/WebLogic

[weblogic] 어플리케이션 deploy 테스트 - dbTest.jsp 예시

weblogic 인스턴스명이 출력되도록 커스터마이징 하였음

dbTest.jsp
0.00MB

 

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="javax.naming.*, javax.sql.*, java.sql.*" %>
<%@ page import="java.util.Properties"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>WebLogic 12.2.1.3 JDBC</title>
</head>
<body>

   <h3>
      ServerName : 
      <%
      String instName=System.getProperty("weblogic.Name");
      %>
    <%=instName%>
    </h3>

   <center>
      <h1>GTPLUS People</h1>
      <table border="3" bordercolor="cornflowerblue">
      <tr bgcolor="cornflowerblue"><td>name<td>gender<td>age</tr>

      <%
      Context ctx = new InitialContext();
      DataSource ds = (DataSource)ctx.lookup("test");
      Connection conn = ds.getConnection();
      Statement stmt = conn.createStatement();
      ResultSet rs = stmt.executeQuery("SELECT name, gender, age FROM people");
      
      Thread.sleep(1000);

      while(rs.next()){
         out.println("<tr>");
         out.println("<td>"+rs.getString("name"));
         out.println("<td>"+rs.getString("gender"));
         out.println("<td>"+rs.getString("age"));
         out.println("</tr>");
      }

      rs.close();
      stmt.close();
      conn.close();
      %>
      </table>
  </center>

</body>
</html>