[java]代码库
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();
}
}
中级程序员
by: 云代码会员 发表于:2019-07-30 14:13:54 顶(0) | 踩(0) 回复
111
回复评论