Live2D

java——连接oracle

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();
}

}

 

posted @ 2021-05-07 13:50  ΜΑΗΑΙΓΞ小白  阅读(67)  评论(0)    收藏  举报