一聚教程网:一个值得你收藏的教程网站

热门教程

jsp 连接oralce数据库并显示记录

时间:2022-06-29 03:15:28 编辑:袖梨 来源:一聚教程网

jsp教程 连接oralce数据库教程并显示记录

public class UserDAO {
    private Connection conn = null;
  private Statement st = null;
 
  public UserDAO() {
 
  try {
  Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
  conn = DriverManager
  .getConnection
  ("jdbc:oracle:thin:@192.168.1.107:1521:ZHUH",
  "zucc","123456");
  } catch (Exception ex) {
  ex.printStackTrace();
  }
  }

  public synchronized void release() {
  if (st != null) {
  try {
  st.close();
  } catch (Exception e) {
  }
  }

  if (conn != null) {
  try {
  conn.close();
  } catch (Exception e) {
  }
  }

  }
  public synchronized boolean checkuser(ActFrmUsers user) throws Exception{
  boolean bl=false;
  try{
  st = conn.createStatement();//这句话放这里
  ResultSet rs=st.executeQuery("select * from users");
  while(rs.next()){
 
  System.out.print("qw");
  }
  }
  catch(Exception ex){
  ex.printStackTrace();
  throw new Exception("数据库查询错误");
  }
  return bl;
  }
}

热门栏目