I've had more problems with my database in the past: It could not always get connection. The database runs on a website (webhosting), and I try to access it from my own PC. Here things go wrong, if I access it from localhost to localhost then it works okay.
Error that I get in Java: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.
I got no clue why, I'm using similar structure as ever, namely the following:
public class SQL {
private final static String USERNAME = "";
private final static String PASSWORD = "";
private final static String URL = "jdbc:mysql://www.fvheeswijk.nl:3306/p28004_bf4";
private static Connection cachedConnection;
private static void createConnection() {
cachedConnection = null;
Properties connectionProperties = new Properties();
connectionProperties.put("user", USERNAME);
connectionProperties.put("password", PASSWORD);
try {
cachedConnection = (Connection) DriverManager.getConnection(URL, connectionProperties);
} catch (SQLException ex) {
Logger.getLogger(SQL.class.getName()).log(Level.SEVERE, null, ex);
}
}
public static Connection getConnection() {
if (cachedConnection == null) {
createConnection();
}
return cachedConnection;
}
}
The data is blanked out of course.
I then tried to ping my website, all fine.
Later I tried to ping www.fvheeswijk.nl:3306
, the database, but Windows cmd cannot find it. Then I tried visiting it via the browser (does this even make sense?), but I got some message along the lines of "packets received out of order". And I have already (way before) added my PC's (Router/Network's) host name to the allowed host list of the database.
Any clue or suggestions what is going wrong?
EDIT: Now I am getting this, might explain something... java.sql.SQLException: null, message from server: "Host '541DB0AA.cm-5-6c.dynamic.ziggo.nl' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'"