开发环境是:jdk1.4.3、resin3.0
dbconn.java:
package com.pixel;import java.sql.*;
import java.util.*;
import java.io.File;
import java.io.*;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;public class DBConn implements Runnable {
    private String jdbcDriver = "";
    private String dbUrl = "";
    private String dbUsername = "";
    private String dbPassword = "";
    private String testTable = "dual";
    private int initialConnections = 10;
    private int incrementalConnections = 5;
    private int maxConnections = 30;
    private Vector connections = null;
   private long wait=30000;
    public DBConn() throws Exception {
        Properties prop = new Properties();
        try {
            //读入配置文件
            prop.load(getClass().getResourceAsStream("/../service_properties.conf"));
            this.jdbcDriver = prop.getProperty("Driver");
            this.dbUrl = prop.getProperty("Url");
            this.dbUsername = prop.getProperty("Username");
            this.dbPassword = prop.getProperty("Password");            log("Web Server connect to : " + dbUrl);
            createPool();            new Thread(this).start();
        } catch (FileNotFoundException ex) {
            throw ex;
        }
    }   public void run() {
    try {
      while (true) {
        Thread.sleep(wait);
        System.out.println(new java.util.Date() + "   开始清理连接池");
        timerEvent();
      }
    }
    catch (InterruptedException e) {
    }
  }
    public int getInitialConnections() {
        return initialConnections;
    }    public void setInitialConnections(int initialConnections) {
        this.initialConnections = initialConnections;
    }
    public int getIncrementalConnections() {
        return incrementalConnections;
    }    public void setIncrementalConnections(
            int incrementalConnections) {
        this.incrementalConnections = incrementalConnections;
    }    public int getMaxConnections() {
        return maxConnections;
    }    public void setMaxConnections(int maxConnections) {
        this.maxConnections = maxConnections;
    }    public String getTestTable() {
        return testTable;
    }    public void setTestTable(String testTable) {
        this.testTable = testTable;
    }    public synchronized void createPool() throws Exception {
        //make sure that createPool hasn't already been called
        if (connections != null) {
            return; //the pool has already been created, return
        }        //instantiate JDBC driver object from init param jdbcDriver
        Driver driver = (Driver)
                (Class.forName(jdbcDriver).newInstance());        DriverManager.registerDriver(driver); //register JDBC driver        connections = new Vector();        //creates the proper number of initial connections
        createConnections(initialConnections);
    }
请问各位怎么解决?多谢各位了,续下

解决方案 »

  1.   

    估计是
    prop.load(getClass().getResourceAsStream("/../service_properties.conf"));
    没有得到配置文件报的错
      

  2.   

    配置文件在:D:\resin\web\WEB-INF目录下
    代码是:
    Driver = oracle.jdbc.driver.OracleDriver
    Url = jdbc:oracle:thin:@127.0.0.1:1521:pixel
    Username = gaokao
    Password = gaokao
      

  3.   

    此service_properties.conf文件应该放D:\resin\web\src\com\下
      

  4.   

    还是报同样的错误,我是这样编译的C:\Program Files\Java\j2re1.4.0_03\bin>java D:\resin\web\src\com\pixel\dbconn.javaException in thread "main" java.lang.NoClassDefFoundError: D:\resin\web\src\com\
    pixel\dbconn/java
      

  5.   

    试试改prop.load(getClass().getResourceAsStream("/../service_properties.conf"));
    为prop.load(getClass().getResourceAsStream("service_properties.conf"));
      

  6.   

    使用java的编程工具把,如jbuilder,eclipse之类的工具.这样应该能找到问题哦
      

  7.   

    你是用的JB吧,如果是JB的话是你的那个数据库的驱动没有配置进来