1.odbc方式
2.jdbc驱动包方式
public static void main(String[] args) {
try {
//Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Class.forName("oracle.jdbc.driver.OracleDriver");
//Connection con=DriverManager.getConnection("jdbc:odbc:scott", "scott", "123456");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl", "scott", "123456");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select * from emp");
while (rs.next()) {
System.out.println(rs.getString(2));
}
rs.close();
stmt.close();
con.close();
} catch (Exception e) {
e.printStackTrace();
}
}