import java.sql.*; public class dfsdfds { public static void main(String[] args) throws ClassNotFoundException, SQLException { // TODO Auto-generated method stub Class.forName("oracle.jdbc.driver.OracleDriver"); Connection ct=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","scott","Orcl123456"); System.out.println("数据库连接成功"); Statement st=ct.createStatement(); ResultSet rt=st.executeQuery("select * from emp"); while(rt.next()){ System.out.println("用户名:"+rt.getString(2)); } rt.close(); st.close(); ct.close(); } }