www.pudn.com > Jsp-Blog.rar > ConnectionPool.java, change:2010-05-19,size:770b


package myblog.commons; 
 
import java.sql.Connection; 
import java.sql.DriverManager; 
import java.sql.SQLException; 
 
 
import javax.sql.DataSource; 
 
public class ConnectionPool { 
 
	private static Connection conn = null; 
 
	private static DataSource ds = null; 
 
	/** 
	 * @return 数据库连接对象 
	 */ 
	public static Connection getConnection() { 
		try { 
			Class.forName("oracle.jdbc.driver.OracleDriver"); 
			String url = "jdbc:oracle:thin:@localhost:1521:twt"; 
			String username = "scott"; 
			String password = "tiger"; 
			conn = DriverManager.getConnection(url, username, password); 
			 
		} catch (SQLException e) { 
 
			e.printStackTrace(); 
		} catch (ClassNotFoundException e) { 
 
			e.printStackTrace(); 
		} 
 
		return conn; 
	} 
 
}