package ODBC; import java.sql.*; public class TestOra { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub try{ //step1.add drives Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); //step2.get connection Connection conn=DriverManager.getConnection("jdbc:odbc:dhyora","scott","tiger"); //step3.creat statement Statement sm=conn.createStatement(); //step4.result set ResultSet rs=sm.executeQuery("select * from emp"); while(rs.next()){//has next System.out.println("用户名:"+rs.getString(2)); } //step5.close all rs.close(); sm.close(); conn.close(); } catch(Exception e){ e.printStackTrace(); } } } 注:要在数据源(ODBC)里添加数据源:dhyora