学习jdbc插入操作
报错1
java.lang.NoClassDefFoundError: Could not initialize class com.napkin.utils.JdbcUtils
解决:
static{
try{
InputStream in = JdbcUtils.class.getClassLoader().getResourceAsStream("db.properties");
Properties properties = new Properties();
properties.load(in);
drive = properties.getProperty("drive");
url = properties.getProperty("url");
username = properties.getProperty("username");
password = properties.getProperty(password);
//加载驱动
Class.forName(drive);
}catch(Exception e){
throw new ExceptionInInitializerError(e);
}
}
password = properties.getProperty(password);
password加上双引号