Hello MashZone Community
I am having trouble running MashZone with Postgres 8.4. This is an open source database. From the release notes I understand that MashZone has not been tested with this database.
I am getting the following error message when trying to execute an sql query:
- "Method org.postgresql.jdbc4.Jdbc4Statement.setQueryTimeout(int) is not yet implemented."
I have been able to connect using several different JDBC drivers all with no problems, but all returning the same error message.
I am assuming that the JDBC drivers of postgres truly don't have time-outs implemented. I have googled the error message and found that other software vendors had to adjust their software accordingly.
Thus my questions: Is it possible to disable the timeout call while executing SQL queries to a database?
Hello Phil,
the flaw occured in the postgres driver itself, unfortunately it obviously does not implement the complete java.sql.Statement interface, so the standard method "setQueryTimeout", which is adressed by MashZone to protect itself from not returning queries, throws this "Not-Implemented"-Exception. So there is no official way to disable the timeout restriction.
I think there are 2 approaches to solve your problem:
You might implement your own postgres-driver just by wrapping the genuine one and then simply catch the Not-Implemented Exception throw by the method, what is quite like hacking and might harm the Mashzone application during runtime.
The recommended and even more convenient solution is to look for a completely implemented postgre driver, perhaps a commercial one with some license fees.
Best regards
Thomas
Thank you Thomas,
I am getting confused. This seems to be a very basic functionality. I've also seen some java testcode that made use of this setQueryTimout() call on a postgres sql "statement", which is where i would assume MashZone uses this function call as well.
Could I be doing something else wrong?
Postgres is one of the most popular and widely spread DBMS that is open source, it seems quite unusual that such basic functionality is not implemented.
Do we know of anyone that has run MashZone with Postgres?
I've also downloaded the jdbc driver from www.enterprisedb.com, however getting same error message. It looks like they are simply reusing the driver of the original DBMS.
It seems my only option is the built that wrapper JDBC driver and catch the SQL exception. I am not really very comfortable with it, but it seems to be the only way right now.
http://jdbc.postgresql.org/todo.html clearly states that this is not implemented
Compliance
- [JDBC1] Implement Statement.setQueryTimeout. →
Along with various forum posts.
I have posted my problem also in postgres JDBC forum:
http://postgresql.1045698.n5.nabble.com/setQueryTimout-tp2856086p2856086.html
Hello Phil,
i took a look at the latest postgre driver source code, what is version 9.0-801 JDBC Source, and there i found this confusing implementation.
snippet from class org.postgresql.jdbc2.AbstractJdbc2Statement.java:
public void setQueryTimeout(int seconds) throws SQLException{
checkClosed();
if (seconds < 0)
throw new PSQLException(GT.tr("Query timeout must be a value greater than or equals to 0."),
PSQLState.INVALID_PARAMETER_VALUE);
if (seconds > 0)
throw Driver.notImplemented(this.getClass(), "setQueryTimeout(int)");
timeout = seconds;
}
I think if you only comment these lines
// if (seconds > 0)
// throw Driver.notImplemented(this.getClass(), "setQueryTimeout(int)");
your problem is fixed. Finally you only have to create a jar file of the whole source and use it instead of the genuine distributed postgre driver.
For sure this is no official supported approach to get the postgre driver running with mashzone, but it should work this way. :-)
Best regards
Thomas
Thats easy for you to say!
It took me a while to figure it out. The closest I came to hacking in the last 7 years, thats for sure. Of course I had to download netbeans and learn to create a *.jar etc.
Anyway I managed to download the source code and change it. I also managed to built that jar file. However it did not work. So I copied my changed jdbc2 statement class from the non working jar file i had compiled into the newest driver from postgres and bingo that worked. I was able to connect and perform a select statement on the database.
Thank you so much for your support!!!