[Java] 连接oracle →→→→→进入此内容的聊天室

来自 , 2021-01-05, 写在 Java, 查看 146 次.
URL http://www.code666.cn/view/cefab442
  1. import java.sql.*;
  2.  
  3. public class dfsdfds {
  4.  
  5. public static void main(String[] args) throws ClassNotFoundException, SQLException {
  6. // TODO Auto-generated method stub
  7.           Class.forName("oracle.jdbc.driver.OracleDriver");
  8.      Connection ct=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","scott","Orcl123456");
  9.      System.out.println("数据库连接成功");
  10.      Statement st=ct.createStatement();
  11.      ResultSet rt=st.executeQuery("select * from emp");
  12.      while(rt.next()){
  13.          
  14.          System.out.println("用户名:"+rt.getString(2));
  15.      }
  16.      rt.close();
  17.      st.close();
  18.      ct.close();
  19. }
  20.  
  21. }

回复 "连接oracle"

这儿你可以回复上面这条便签

captcha