www.pudn.com > restrant.zip > BaseDao.java, change:2014-01-25,size:800b


package com.alex.restrantol.base; 
 
import java.sql.*; 
 
public class BaseDao { 
 
	public Connection getConn() { 
		try { 
			Class.forName("com.mysql.jdbc.Driver"); 
			return DriverManager.getConnection( 
					"jdbc:mysql://localhost:3306/eshop","root","root"); 
		} catch (Exception e) { 
			e.printStackTrace(); 
		} 
		return null; 
	} 
 
	public void closeAll(Connection con, PreparedStatement ps, ResultSet rs) { 
		try { 
			if (rs != null) { 
				rs.close(); 
			} 
		} catch (SQLException e) { 
			e.printStackTrace(); 
		} 
 
		try { 
			if (ps != null) { 
				ps.close(); 
			} 
		} catch (SQLException e) { 
			e.printStackTrace(); 
		} 
 
		try { 
			if (con != null && (!con.isClosed())) { 
				con.close(); 
			} 
		} catch (SQLException e) { 
			e.printStackTrace(); 
		} 
	} 
}