import java.sql.*; /** DBConnection <br> Last UpDate :August. 7. 2001. Tuesday.<br> Developer : Young Sick. Yoon <<a href="mailto:wizard@ncafe.net">wizard@ncafe.net</a>><br>*/ public class DBconn { private Connection connection; private Statement statement; private LogFile log; public DBconn(){ log = new LogFile(); try { Class.forName("weblogic.jdbc20.pool.Driver").newInstance(); } catch(Exception me) { log.errLog("Err Class : DBconn.class"); log.errLog("DriverManager Error : "+me.getMessage()); } try { connection = DriverManager.getConnection("jdbc20:weblogic:pool:irisPool"); try { statement=connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); } catch(SQLException e) { log.errLog("Err Class : DBconn.class"); log.errLog("createStatement Error : "+e.getMessage()); if (connection!=null) { try { connection.close(); } catch(SQLException ce) { log.errLog("Err Class : DBconn.class"); log.errLog("Connection Close Error : "+ce.getMessage()); } } } } catch(SQLException e){ log.errLog("Err Class : DBconn.class"); log.errLog("getConnection Error : "+e.getMessage()); } } /** ResultSet 을 구함 */ public ResultSet executeQuery(String sql) throws SQLException{ return statement.executeQuery(sql); } /** Update 나 Delete, Create, Drop 등을 위한 Methed */ public int executeUpdate(String sql) throws SQLException{ return statement.executeUpdate(sql); } /** 항상 clean() 을 해줘야 합니다. */ public void clean(){ if (statement!=null) { try { statement.close(); } catch(SQLException e) { log.errLog("Err Class : DBconn.class"); log.errLog("statement Close Error : "+e.getMessage()); } } if (connection!=null) { try { connection.close(); } catch(SQLException e) { log.errLog("Err Class : DBconn.class"); log.errLog("Connection Close Error : "+e.getMessage()); } } } }
649 view
4.0 stars
SSISO Community