📄 a09a80c36faa001d1a45a5aecb698fca
字号:
package com;
import java.sql.*;
public class DAO {
private static Connection conn = null;
private static String driver = "oracle.jdbc.driver.OracleDriver";
private static String url = "jdbc:oracle:thin:@localhost:1521:NEUSOFT";
private static String user = "SCOTT";
private static String pwd = "TIGER";
private static Statement stmt = null;
private static ResultSet rs = null;
public static Connection getConnection(){
try{
Class.forName(driver).newInstance();
conn = DriverManager.getConnection(url,user,pwd);
if(conn!=null){
System.out.println("连接Oracle数据库成功!");
}
}catch(Exception ex){
System.out.println(ex.getMessage());
}
return conn;
}
public static ResultSet getEmployee(){
conn = DAO.getConnection();
try{
stmt = conn.createStatement();
rs = stmt.executeQuery("select * from t_hong_userinfo");
}catch(Exception ex){
ex.printStackTrace();
}finally{
}
return rs;
}
public static void closeconn(){
if(rs!=null){
try{
rs.close();
}catch(Exception e){
e.printStackTrace();
}
}
if(stmt!=null){
try{
stmt.close();
}catch(Exception e){
e.printStackTrace();
}
}
if(conn!=null){
try{
conn.close();
}catch(Exception e){
e.printStackTrace();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -