Here you can find the source of getConnection(String ip, String serviceName, String uid, String pwd)
public static Connection getConnection(String ip, String serviceName, String uid, String pwd) throws Exception
//package com.java2s; import java.sql.Connection; import java.sql.DriverManager; public class Main { public static Connection getConnection(String ip, String serviceName, String uid, String pwd) throws Exception { String driver = "oracle.jdbc.driver.OracleDriver"; String url = "jdbc:oracle:thin:@" + ip + ":1521:" + serviceName; // String url = "jdbc:oracle:thin:@localhost:1521:ORCL11"; // String uid = "dep"; // String pwd = "dep"; // String url = "jdbc:oracle:thin:@172.29.24.13:1521:dep1"; // String uid = "deptestnew"; // String pwd = "deptestnew"; Class.forName(driver);//from w w w . j ava2 s . c om Connection conn = DriverManager.getConnection(url, uid, pwd); return conn; } }