MySQL NullPointerException

Discussion in 'Plugin Development' started by Pezah, Jan 4, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    Pezah

    Code:java
    1. @Override
    2. public Connection openConnection() {
    3. try {
    4. Class.forName("com.mysql.jdbc.Driver");
    5. connection = DriverManager.getConnection("jdbc:mysql://" + this.hostname + ":" + this.port + "/" + this.database, this.user, this.password);
    6. } catch (SQLException e) {
    7. plugin.getLogger().log(Level.SEVERE, "Could not connect to MySQL server! because: " + e.getMessage());
    8. } catch (ClassNotFoundException e) {
    9. plugin.getLogger().log(Level.SEVERE, "JDBC Driver not found!");
    10. }
    11. return connection;
    12. }


    ' plugin.getLogger().log(Level.SEVERE, "Could not connect to MySQL server! because: " + e.getMessage());'

    ^ That is getting a nullPointerException but not sure why how how it could be null, could someone please help me out? Thanks.
     
  2. Offline

    ImDeJay

    looks like plugin may be null... make sure you declared it in your code.

    on another notce, e.getmessage might be null.
     
Thread Status:
Not open for further replies.

Share This Page