Spring
스프링 퀵스타트를 이용해서 스프링 기초를 연습하는 글입니다.
git 소스 주소
Oracle 사용자 등록
권한 부여
JSP MODEL 1방식 테스트
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
| package com.springbook.biz.common;
import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet;
public class JDBCUtil { public static Connection getConnection() { try { Class.forName("oracle.jdbc.driver.OracleDriver"); return DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "admin", "1234"); } catch (Exception e) { e.printStackTrace(); } return null; }
public static void close(PreparedStatement stmt, Connection conn) { if (stmt != null) { try { if (!stmt.isClosed()) stmt.close(); } catch (Exception e) { e.printStackTrace(); } finally { stmt = null; } } if (conn != null) { try { if (!conn.isClosed()) conn.close(); } catch (Exception e) { e.printStackTrace(); } finally { conn = null; } } }
public static void close(ResultSet rs, PreparedStatement stmt, Connection conn) { if (rs != null) { try { if (!rs.isClosed()) rs.close(); } catch (Exception e) { e.printStackTrace(); } finally { rs = null; } } if (stmt != null) { try { if (!stmt.isClosed()) stmt.close(); } catch (Exception e) { e.printStackTrace(); } finally { stmt = null; } } if (conn != null) { try { if (!conn.isClosed()) conn.close(); } catch (Exception e) { e.printStackTrace(); } finally { conn = null; } } } }
|