connection con =null;
try {
// class.forname("oracle.jdbc.driver.oracledriver");//注冊驅動第一種方式***************
driver drv = new oracle.jdbc.driver.oracledriver();//注冊驅動第二種方式 *******************88
drivermanager.registerdriver(drv);
// string url="jdbc:oracle:"+"thin:@localhost:1521:orcl";//獲得連接配接的第一種方式******************
// string user="lhy";
// string password="lhy";
// con=drivermanager.getconnection(url, user, password);
properties pro = new properties();//獲得連接配接的第二種方法*******************************
pro.setproperty("user","lhy");
//鍵是user,不是username
pro.setproperty("password","lhy");
con = drivermanager.getconnection("jdbc:oracle:thin:@localhost:1521:orcl",pro);