首先让虚拟机和本机能互相ping通,此处不在赘述。纯粹是虚拟机的配置、接下来直接进入正题
从安装oracle的虚拟机中找到以下路径的jdbc文件

(1)将jdbc驱动包复制到lib。
(2)build path。
(3)创建java文件

将下面的代码写进java文件中
package com.jredu.servlet.oracle;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class Connect {
private static String url = "jdbc:oracle:thin:@192.168.0.136:1521/orcl";
private static String user = "scott";
private static String password = "tiger";
public static void main(String[] args) throws SQLException, ClassNotFoundException {
Class.forName("oracle.jdbc.OracleDriver");
Connection con = DriverManager.getConnection(url,user,password);
System.out.println(con);
}
}
运行。得出下面结果。即连通
