www.pudn.com > Java_web_shipin_gongsi-.rar > DBConnection.java, change:2011-12-14,size:792b


package common; 
 
import java.sql.Connection; 
import java.sql.DriverManager; 
import java.sql.ResultSet; 
import java.sql.SQLException; 
 
public class DBConnection { 
   
	public static Connection getDBConnection(){ 
		try { 
			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 
			Connection con = DriverManager.getConnection("jdbc:odbc:food"); 
			return con; 
		 
		} catch (ClassNotFoundException e) { 
			e.printStackTrace(); 
		} catch (SQLException e) { 
			e.printStackTrace(); 
		} 
		return null; 
	} 
	public static void main(String args[]) throws SQLException{ 
 
	} 
	 
	public static void  close(Connection con){ 
		if(con!=null){ 
			try { 
				con.close(); 
			} catch (SQLException e) { 
				// TODO Auto-generated catch block 
				e.printStackTrace(); 
			} 
		} 
	} 
 
}