Oracle四种登录方式
1.SQL plus
2.SQL Developer
3.PLSQL Developer
前面三种没有什么可以说的,基本上就是安装软件就可以使用
4.JDBC 连接
public static void main(String[] args) {
Connection conn = null;
Statement stat = null;
try{
Class.forName("oracle.jdbc.OracleDriver");
String url="jdbc:oracle:thin:@localhost:1521:orcl";
String user="scott";
String password="tiger";
conn = DriverManager.getConnection(url,user,password);
stat = conn.createStatement();
ResultSet rs = stat.executeQuery("select * from emp");
if(rs != null){
while(rs.next()){
System.out.println("员工号:"+rs.getInt("empno")+"姓名:"+rs.getString("ename"));
}
}
rs.close();
}catch(Exception e){
e.printStackTrace();
}finally{
if(stat != null){
try {
stat.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
if(conn!=null){
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}