Thursday, 22 August 2013

Is there any time limit when we access a database?

Is there any time limit when we access a database?

Well. I just recently come into conclusion about this one. Is there any
time limit when we access the database? To be precise, MySQL database
accessed through Java's JDBC and driver provided by MySQL?
To know more precisely what happen, I give you more detail:
So I got a website that actually provide RESTful webservice, which also
backed with Kitty-Cache for caching, because some computational is
expensive to do. I run the project, and I access all the api address from
browser, and all is well.
Strange is when I did not shut down my computer, and today I access again,
the address that has something to do with database (MySQL) just error,
internal server error, and the error is caused by NullPointerException in
a place where it should not happen. I stopped the project, run it again,
access the same address, and it displayed the data.
Is there any time limit? How we can refresh the database connection? I
think I will try to re-connect it again, but I am not sure how.
Code:
java.sql.Connection conn = null;
try {
Class.forName("com.mysql.jdbc.Driver");
String conStr =
"jdbc:mysql://" + this.dbHostname +
":" + this.dbPort + "/" + this.dbName;
conn = DriverManager.getConnection(conStr, this.dbUsername,
this.dbPassword);
this.isConnectingSuccess = true;
} catch (ClassNotFoundException cnfe) {
throw new IllegalDbCmdExecution(cnfe.getMessage());
} catch (SQLException sqle) {
throw new IllegalDbCmdExecution(sqle.getMessage());
}

No comments:

Post a Comment