package com.zc.struts.db; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class DBConnection { //ע���� static{ try{ Class.forName("oracle.jdbc.driver.OracleDriver"); }catch(Exception e) { e.printStackTrace(); } } //��bl�� public static Connection getConnection(){ Connection connection = null; try { connection =DriverManager.getConnection("jdbc:oracle:thin:@192.168.0.45:1521:orcl","shiqi","shiqi"); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return connection; } public static void close(Connection con, Statement st, ResultSet rs) { try { if (rs != null) { rs.close(); } } catch (SQLException e) { e.printStackTrace(); } finally { try { if (st != null) { st.close(); } } catch (SQLException e) { e.printStackTrace(); } finally { try { con.close(); } catch (SQLException e) { e.printStackTrace(); } } } } }