包导入好了 在DAO中写好方法selectAllProduce()在WEB下运行就会出现这个错误,而在DAO中写main方法运行就没有问题 求大哥帮忙!
public class JdbcUtil {
private final static Properties props = new Properties();
static {
InputStream in = JdbcUtil.class.getClassLoader().getResourceAsStream(
"jdbc.properties");
try {
props.load(in);
} catch (IOException ex) {
throw new RuntimeException("加载属性文件失败");} finally {
try {in.close();} catch (IOException ex) {}
in = null;
} }private static DataSource ds;
static {String url = props.getProperty("jdbc.url");
String username = props.getProperty("jdbc.username");
String password = props.getProperty("jdbc.password");
String driverClass = props.getProperty("jdbc.driverClass");
BasicDataSource bds = new BasicDataSource();
bds.setUrl(url);
bds.setUsername(username);
bds.setPassword(password);
bds.setDriverClassName(driverClass);
ds = bds;
}public static Connection getConnection() throws SQLException {
Connection conn = ds.getConnection();
return conn;}