package com.jdbc.odbc;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class Jdbc_Demo {
public static void main(String[] args) {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection ct = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","scott","tiger");
Statement st = ct.createStatement();
ResultSet rs = st.executeQuery("select * from emp");
while(rs.next()){
System.out.println("用户名:"+rs.getString(2));
}
rs.close();
st.close();
ct.close();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
posted on 2011-09-26 21:57
Java_liyadong 阅读(143)
评论(0) 编辑 收藏