如果表emp为空 则正常运行
如果emp有记录 有一条 或几条 都出错
rs = stmt.executeQuery("insert ……");
不出错。
大虾们 帮忙解释一下~
谢先

解决方案 »

  1.   

    /**
      *
      *           连接数据库 
      *
      *  方法 getConnection() 和 closeConnection()
      *
      */import oracle.jdbc.driver.*;
    import java.io.*;
    import java.lang.reflect.Method;
    import java.lang.*;
    import java.sql.*;
    import java.util.*;
    import java.net.*;public class ConnectionDataBaseBean
    {
       static Connection conn = null;  public ConnectionDataBaseBean()
      {
      }
      /**get oracle connection*/
      public static Connection getConnection()
      {
        try
        {
          Class.forName("oracle.jdbc.driver.OracleDriver");
          conn = DriverManager.getConnection(
              "jdbc:oracle:thin:@localhost:1521:pdb", "scott", "tiger");
        }
        catch (ClassNotFoundException errs)
        {
          System.err.println("ConnectionDataBaseBean.getConnection() ClassNotFoundException:"
                             + errs.getMessage());
        }
        catch (SQLException errs)
        {
          System.err.println("ConnectionDataBaseBean.getConnection()SQLException:"
                             + errs.getMessage());
        }
        return conn;
      }
      /**close oracle connection*/
      public static void closeConnection()
      {
        try
        {
          if (conn != null)
          {
            conn.close();
          }
        }
        catch (SQLException errs)
        {
          System.err.println("ConnectionDataBaseBean.closeConnection()SQLException:"
                             + errs.getMessage());
        }
        finally
        {
            conn = null;
        }
      }
    }
    /**
      *               用户合法性检测
      *
      */
    import java.io.*;
    import java.lang.*;
    import java.sql.*;
    import java.util.*;
    import org.apache.struts.action.*;
    ……public class CheckUserBean {
      static Connection conn;
      Statement stmt;
      ResultSet rs;
      private String str_Sql;
      private String str_id;
      private String str_password;
      private String str_identity;
      boolean boo_isvalidate=false;
      ActionErrors errors = new ActionErrors();  public boolean CheckUserBean(User user)throws Exception {/** 为了 测试 下面代码 暂时屏蔽掉了
       str_id = user.getStr_id();
       str_password = user.getStr_password();
       str_identity = user.getStr_identity();   if (str_identity.equals("manager"))
        {
          str_Sql ="select * from emp where empno= '7934'";
          System.err.println("db.executeQuery:select * from emp where empno= '7934'");
        }
        else if(str_identity.equals("student"))
        {
          str_Sql =
              "Select User_Stu_ID,User_PassWord  from UserInfo where User_Stu_ID ='"
              +str_id + "'and User_PassWord ='" +str_password + "' ";
          System.err.println("db.executeQuery:student do ");
        }
    */ try {
          System.out.println(" succeed into try");
       if (conn == null){
                        //测试用输出
                        System.out.println(" conn is null init conn …… ……");
            conn = ConnectionDataBaseBean.getConnection();}
       if (conn != null) {
                         //测试用输出
                        System.out.println(" conn inited ");
         stmt = conn.createStatement();
                          //测试用输出                    
                          System.out.println("createStatement succeed");
         rs = stmt.executeQuery("select * from emp where empno= '7934'");
                          //测试用输出
                        System.out.println("EXE: select * from emp where empno= '7934'");
    //    if (rs.next()) {
           boo_isvalidate = true;
                           //测试用输出
                          System.out.println(“return in try:" +boo_isvalidate);
    //    }
       }
     }
     catch (Exception ex) {
       System.err.println("db.executeQuery:much time again " + ex.getMessage());
     }
               //测试用输出
              System.out.println(“return:" +boo_isvalidate);
       return  boo_isvalidate;  }
    }
    ///////////////////////////////////////////////////////
    //----------------以下是运行 出错过程————————//
    /////////////////////////////////////////////////////////执行 select * from emp where empno= '7934'StandardWrapper[:invoker]: Loading container servlet invoker
    HttpConnector[8083] Starting background thread
     succeed into try
     conn is null init conn …… ……
     conn inited 
    createStatement succeed
    db.executeQuery:much time again ORA-00600: 内部错误代码,参数: [ttcgcshnd-1], [0], [], [], [], [], [], []
    return:false
    //PL/SQL运行结果
    //==========================================================================
    SQL*Plus: Release 9.0.1.0.1 - Production on D??úáù 1?? 10 13:12:09 2004(c) Copyright 2001 Oracle Corporation.  All rights reserved.
    á??óμ?: 
    Oracle9i Enterprise Edition Release 9.0.1.1.1 - Production
    With the Partitioning option
    JServer Release 9.0.1.1.1 - ProductionSQL> select * from emp where empno= '7934';     EMPNO ENAME      JOB              MGR HIREDATE          SAL       COMM
    ---------- ---------- --------- ---------- ---------- ---------- ----------
        DEPTNO
    ----------
          7934 MILLER     CLERK           7782 23-1?? -82       1300
            10SQL>
    //=================================================================================
      

  2.   

    应用服务器用weblogic就行了。