Mercurial > hg > monetdb-java
view tests/BugSetQueryTimeout_Bug_3357.java @ 14:3fa949cbc783
Implemented Statement methods: getQueryTimeout() and setQueryTimeout(int seconds).
getQueryTimeout() used to always return 0, now it returns the query timeout retrieved from the server.
setQueryTimeout(int seconds) used to always throw SQLException: query time outs not supported.
Now it sets the query timeout for the current connection/session on the server.
This fixes bug 3357
author | Martin van Dinther <martin.van.dinther@monetdbsolutions.com> |
---|---|
date | Thu, 06 Oct 2016 16:47:54 +0200 (2016-10-06) |
parents | |
children | 04fbf3655452 |
line wrap: on
line source
/* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * Copyright 1997 - July 2008 CWI, August 2008 - 2016 MonetDB B.V. */ import java.sql.*; public class BugSetQueryTimeout_Bug_3357 { public static void main(String[] args) throws Exception { Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); Connection con = DriverManager.getConnection(args[0]); Statement st = con.createStatement(); try { System.out.println("QueryTimeout = " + st.getQueryTimeout()); st.setQueryTimeout(123); System.out.println("QueryTimeout = " + st.getQueryTimeout()); st.setQueryTimeout(2134567890); System.out.println("QueryTimeout = " + st.getQueryTimeout()); st.setQueryTimeout(0); System.out.println("QueryTimeout = " + st.getQueryTimeout()); st.setQueryTimeout(-1); // to generate an SQLException as negative timeouts are invalid System.out.println("QueryTimeout = " + st.getQueryTimeout()); } catch (SQLException se) { System.out.println("setQueryTimeout(timeout_value) throws: " + se); } finally { st.close(); } con.close(); } }