Uploaded image for project: 'MariaDB Connector/J'
  1. MariaDB Connector/J
  2. CONJ-487

No timeout exception on query with sleep(50) and querytimeout(1)

    XMLWordPrintable

Details

    Description

      I try to create a timeout exception with the current mariadb connector.
      For this i create a select statement with the sleep value of 50 seconds but a querytimeout value of 1.

      the query runs all the 50 seconds and has a return value - see log information "has next"

      Is the handling from my side correct?

      final String sql = "SELECT sleep(50)";
       
      	        try (final PreparedStatement preparedStatement = dbCon.getPreparedStatement(sql)) {
      	            logger.info("### Prepared Statement: " + preparedStatement);
       
      	            preparedStatement.setQueryTimeout(1);
      	            final ResultSet rowset = preparedStatement.executeQuery();
      	            logger.info("### Finsih Statement: " + rowset.toString());
      	            logger.info("### Has next: " + rowset.next());
      	        } catch (final Exception e) {
      	            logger.severe(e.getMessage());
      	        }
      	        
      	        try (final Statement statement = dbCon.getStatement()) {
      	            logger.info("### Statement: " + statement );
       
      	            statement .setQueryTimeout(1);
      	            final ResultSet rowset = statement .executeQuery(sql);
      	            logger.info("### Finsih Statement: " + rowset.toString());
      	            logger.info("### Has next: " + rowset.next());
      	        } catch (final Exception e) {
      	            logger.severe(e.getMessage());
      	        }
      

      Jun 02, 2017 9:42:48 AM com.mariadb.conj.QueryTimeoutIssue selectEntry
      INFORMATION: ### Prepared Statement: sql : 'SELECT sleep(50)', parameters : []
      Jun 02, 2017 9:43:38 AM com.mariadb.conj.QueryTimeoutIssue selectEntry
      INFORMATION: ### Finsih Statement: org.mariadb.jdbc.internal.com.read.resultset.SelectResultSet@4629104a
      Jun 02, 2017 9:43:38 AM com.mariadb.conj.QueryTimeoutIssue selectEntry
      INFORMATION: ### Has next: true
      Jun 02, 2017 9:43:38 AM com.mariadb.conj.QueryTimeoutIssue selectEntry
      INFORMATION: ### Statement: org.mariadb.jdbc.MariaDbStatement@27f8302d
      Jun 02, 2017 9:43:39 AM com.mariadb.conj.QueryTimeoutIssue selectEntry
      INFORMATION: ### Finsih Statement: org.mariadb.jdbc.internal.com.read.resultset.SelectResultSet@4d76f3f8
      Jun 02, 2017 9:43:39 AM com.mariadb.conj.QueryTimeoutIssue selectEntry
      INFORMATION: ### Has next: true
      

      Attachments

        Activity

          People

            diego dupin Diego Dupin
            fahrenholz sfahren
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.