连接到数据库时为空指针

时间:2017-11-08 21:24:59

标签: java

我正在尝试使用phpMyadmin连接到数据库,但我在属性中得到一个nullpointer

这是我的代码:

const o = {
  a: 1,
  b: undefined,
  c: 2345,
  d: null,
};

const r = Object.keys(o).filter((v) => o[v]).reduce((s, a) => ({
  ...s,
  [a]: o[a],
}), {});

console.log(r);

这里是nullpointer发生的地方:

public Connection getConnection() throws SQLException {
        final String ip = prop.getProperty("database_ip");
        final String dir = prop.getProperty("database_dir");
        final String username = prop.getProperty("database_username");
        final String password = prop.getProperty("database_password");

        try {
            Class.forName("com.mysql.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            throw new IllegalStateException("No suitable driver found");
        }
        return DriverManager.getConnection("jdbc:mysql://" + ip + "/" + dir, username, password);
    }

这是我的地图结构: enter image description here

0 个答案:

没有答案