헤르메스 LIFE

[Source] Connection Test 본문

JSP&JavaScript&HTML

[Source] Connection Test

헤르메스의날개 2012. 5. 14. 19:46
728x90
<%@ page contentType="text/html; charset=euc-kr" %>   
<%@ page import="java.sql.*,java.text.*,java.util.*,java.text.Format.*"%> 
<%@ page import="javax.naming.*,javax.sql.*" %> 
<%
    String strsql   = "select count(*) from test_10"; 
    Connection conn = null; Statement stmt = null; 
    ResultSet rset = null;  
    
    try {         
        Context ctx = new InitialContext();         
        DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/SpringDS");           
        
        conn = ds.getConnection();
        out.println("conn :: " + conn);
        stmt = conn.createStatement();
        rset = stmt.executeQuery(strsql);
        
        while (rset.next()) {                 
        	out.println(rset.getString(1));         
        }   
    }catch(Exception e){
        out.println("Error : ");         
        out.println(e.getMessage());  
    } finally {         
        if ( rset != null ) rset.close();         
        if ( stmt != null ) stmt.close();         
        if ( conn != null ) conn.close(); 
    }
%>

https://hermeslog.tistory.com/628

 

[Source] JDBC Connection Test && JDBC Version 확인

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="java.sql.*"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/..

hermeslog.tistory.com

 

728x90