jdbc连接oracle

		Class.forName("oracle.jdbc.driver.OracleDriver");
		Connection con = DriverManager.getConnection("jdbc:oracle:thin:@{ip}:{port}:{servername}",{username},"pw"
	
//{ip}:oracle服务器ip
//{port}oracle 商品
{servername}oracle 服务器名

 

可由oracle客户端的 oracle\product\10.2.0\client_1\NETWORK\ADMIN\TNSNAMES.ORA文件得到{ip}{port}{servername}

TNSNAMES.ORA文件:

mytest =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 172.20.0.42)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = sgpmdb)            //{servername}
    )
  )

 

你可能感兴趣的:(oracle)