赞
踩
package com.etc.cn;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class BascDao {
public static void main(String[] args) {
Connection conn=null;
//加载数据步骤
//1.加载驱动
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
//2.建立与数据库的连接
conn=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","sa","sa123");
System.out.println("连接成功");
} catch (Exception e) {
e.printStackTrace();
}
finally{
if(conn!=null){
try {
conn.close();
System.out.println("成功关闭");
} catch (SQLException e) {
e.printStackTrace();
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。