PreparedStatement won't ever timeout even if explicitly set
问题 I am trying to simulate an scenario where my service loses connection to a database and cannot do an INSERT by blocking the connection with iptables, but I can't make the executeQuery() method to timeout. What I did is setting a timeout for the PreparedStatement like this statement.setQueryTimeout(5) . Here is the code. HikariConfig config = new HikariConfig(); config.setJdbcUrl("jdbc:mysql://db-url/db"); config.setUsername("user"); config.setPassword("passwd"); config.setMaximumPoolSize(10);