Java jdbc 连接oracle
2016-12-19 15:40 甘雨路 阅读(280) 评论(0) 编辑 收藏 举报import java.sql.Connection; import java.sql.Driver; import java.sql.DriverManager; import java.sql.SQLException; import java.util.Properties; import org.junit.Test; public class Demo { @Test public void fun() throws ClassNotFoundException,SQLException{ //连接数据库的步骤 //1创建driver类的实现对象 Driver driver = new oracle.jdbc.driver.OracleDriver(); // 路径 String url = "jdbc:oracle:thin:@localhost:1521:orcl"; // 配置账号密码 Properties info = new Properties(); info.put("user", "LF"); info.put("password", "LF"); // 2 调用driver的connect()方法连接数据库 Connection con = driver.connect(url, info); System.out.println(con); } }