a. 倒入oracle的jar包
b. 编写java文件
package com.sp;
import java.sql.*;
//使用jdbc连接oracle
public class MyOra2 {/*** @param args*/public static void main(String[] args) {// TODO Auto-generated method stubtry {Class.forName("oracle.jdbc.driver.OracleDriver");Connection cc = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:MyOra1","scott","tiger");Statement sm = cc.createStatement();ResultSet rs = sm.executeQuery("select * from emp");while (rs.next()) {//打印用户名System.out.println("用户名 :" + rs.getString(2));}} catch (Exception e) {// TODO Auto-generated catch blocke.printStackTrace();}}}
oracle的jar包下载地址:classes12.jar