只需要实现一个功能,所以只写一个方法,为了方便调用,设为静态方法
package com.jv; import java.sql.Connection;
import java.sql.DriverManager; public class Lianjie { //静态方法获取连接对象
public static Connection getLianj() throws Exception
{ Class.forName("oracle.jdbc.driver.OracleDriver"); String url = "jdbc:oracle:thin:@localhost:1521:orcl"; Connection conn = DriverManager.getConnection(url, "test","test"); return conn; }
}