麻烦大家看下谢谢 !空指针问题 新手求解决办法
public class TextJdbc {
public void Text1Driver() throws Exception {
String driverClass = null;
String url = null;
String user = null;
Object password = null;
// 读取类路径下的jdbcdfile文件
InputStream is = getClass().getClassLoader().getResourceAsStream("jdbc.properties");
Properties properties = new Properties();
properties.load(is); //提示在这出现空指针异常
driverClass = properties.getProperty("driver");
url = properties.getProperty("url");
user = properties.getProperty("user");
password = properties.getProperty("password");
Driver driver = (Driver) Class.forName(driverClass).newInstance();
Properties info = new Properties();
info.put("user", user);
info.put("password", password);
Connection connection = (Connection) driver.connect(url, info);
}
public static void main(String[] args) throws Exception {
TextJdbc tj = new TextJdbc();
tj.Text1Driver();
}
}