MyOracleMIS.properties放在DBConnection.class所在路径建议采用
InputStream is  = getClass().getResourceAsStream("/MyOracleMIS.properties");这样该文件就位于/WEB-INF/classes

解决方案 »

  1.   

    把MyOracleMIS.properties加入到CLASSPATH
      

  2.   

    还是不行啊!
    我将MyOracleMIS.properties放在了classes\zbsjk\dbconnection下面(合DBConnection.class一起)
    可错误提示还是一样!
      

  3.   

    加入CLASSPATH????
    求具体操作!
    谢谢
      

  4.   

    icecloud(冰云):
    建议采用
    InputStream is  = getClass().getResourceAsStream("/MyOracleMIS.properties");这样该文件就位于/WEB-INF/classes
    什么意思?
      

  5.   

    简单办法和zbsjk.dbconnection 放一个目录下。
      

  6.   

    就是把那个文件的路径加入到CLASSPATH环境变量
      

  7.   

    楼上那位兄弟的方法我也试过了
    可还是不行啊!
    我的JAVA 文件如下:
    package zbsjk.dbconnection;import java.io.*;
    import java.sql.*;
    import java.util.Properties;public class DBConnection
    {    public DBConnection()
        {
            File file = new File("MyOracleMIS.properties");
            String s = file.getAbsolutePath().replace('\\', '/');
            Properties properties = new Properties();
            try
            {
                FileInputStream fileinputstream = new FileInputStream(s);
                properties.load(fileinputstream);
                if(fileinputstream != null)
                    fileinputstream.close();
            }
            catch(IOException ioexception)
            {
                System.out.println("无法打开配置文件");
            }
            db_type = properties.getProperty("db_type");
            user = properties.getProperty("user");
            password = properties.getProperty("password");
            byte byte0 = 2;
            if(db_type.equals("oracle"))
                byte0 = 1;
            switch(byte0)
            {
            default:
                break;        case 1: // '\001'
                db_ip = properties.getProperty("db_ip");
                db_port = properties.getProperty("db_port");
                db_uid = properties.getProperty("db_uid");
                try
                {
                    Class.forName("oracle.jdbc.driver.OracleDriver");
                }
                catch(ClassNotFoundException classnotfoundexception)
                {
                    System.out.println("数据库驱动加载错误");
                    classnotfoundexception.printStackTrace();
                }
                String s1 = user + "/" + password + "@" + db_ip + ":" + db_port + ":" + db_uid;
                try
                {
                    db_conn = DriverManager.getConnection("jdbc:oracle:thin:" + s1);
                }
                catch(SQLException sqlexception)
                {
                    System.out.println("数据库连接错误");
                    sqlexception.printStackTrace();
                }
                break;        case 2: // '\002'
                db_driver = properties.getProperty("db_driver");
                db_url = properties.getProperty("db_dsn");
                try
                {
                    Class.forName(db_driver);
                }
                catch(ClassNotFoundException classnotfoundexception1)
                {
                    classnotfoundexception1.printStackTrace();
                }
                try
                {
                    db_conn = DriverManager.getConnection(db_url, user, password);
                }
                catch(SQLException sqlexception1)
                {
                    sqlexception1.printStackTrace();
                }
                break;
            }
        }    public void setuser(String s)
        {
            user = s;
        }    public void setpassword(String s)
        {
            password = s;
        }    public String getuser()
        {
            return user;
        }    public String getpassword()
        {
            return password;
        }    public String getdbtype()
        {
            return db_type;
        }    public int getrecordcount()
        {
            return record_count;
        }    public int getfieldcount()
        {
            return field_count;
        }    public ResultSet executeQuery(String s)
            throws SQLException
        {
            db_stmt = db_conn.createStatement();
            int i = s.indexOf("from");
            if(i < 0)
                i = s.indexOf("FROM");
            String s1 = s.substring(i);
            s1 = "select count(*) " + s1;
            db_rset = db_stmt.executeQuery(s1);
            if(db_rset.next())
                record_count = db_rset.getInt(1);
            db_rset = db_stmt.executeQuery(s);
            ResultSetMetaData resultsetmetadata = db_rset.getMetaData();
            field_count = resultsetmetadata.getColumnCount();
            return db_rset;
        }    public int executeUpdate(String s)
            throws SQLException
        {
            db_stmt = db_conn.createStatement();
            return db_stmt.executeUpdate(s);
        }    public String getColumnName(int i)
            throws SQLException
        {
            ResultSetMetaData resultsetmetadata = db_rset.getMetaData();
            return resultsetmetadata.getColumnName(i);
        }    public String getData(int i)
            throws SQLException
        {
            return db_rset.getString(i).trim();
        }    public String getData(String s)
            throws SQLException
        {
            return db_rset.getString(s).trim();
        }    public boolean next()
            throws SQLException
        {
            return db_rset.next();
        }    public void close()
            throws SQLException
        {
            if(db_conn != null)
                db_conn.close();
            if(db_stmt != null)
                db_stmt.close();
            if(db_rset != null)
                db_rset.close();
        }    public Connection getConnection()
        {
            return db_conn;
        }    public CallableStatement spCall(String s)
            throws Exception
        {
            return db_conn.prepareCall(s);
        }    public String db_ip;
        public String db_port;
        public String db_uid;
        public String user;
        public String password;
        public String db_driver;
        public String db_url;
        public String db_type;
        public String Sqlstring;
        public Connection db_conn;
        public Statement db_stmt;
        public ResultSet db_rset;
        public int record_count;
        public int field_count;
    }
    多谢各位大虾指点!