import java.sql.Connection;
import java.sql.DriverManager;
public class OracleDemo {
private static final String DBDRIVER = "oracle.jdbc.driver.OracleDriver";
private static final String DBURL = "jdbc:oracle:thin:@localhost:1521:acehzh";// 本机数据库
private static final String USER = "scott";
private static final String PASSWORD = "tiger";
public static void main(String[] args) throws Exception {
// 1.加载数据库驱动程序,此时不需要实例化,因为容器自己负责管理
Class.forName(DBDRIVER);
// 2.连接数据库
Connection con = DriverManager.getConnection(DBURL, USER, PASSWORD);
System.out.println(con);
// 3.关闭数据库
con.close();
}
}