@SuppressFBWarnings( value = "SQL_NONCONSTANT_STRING_PASSED_TO_EXECUTE", justification = "It is known that this command is unsafe. We need" + "to improve it as soon as we can") @Override public Iterator<ValueRow<ScalarValue<?>>> select(String query) throws UserToroException { Connection connection = getJooqConf().connectionProvider().acquire(); try { try (Statement st = connection.createStatement()) { //This is executed to force read only executions st.executeUpdate("SET TRANSACTION ISOLATION LEVEL SERIALIZABLE"); st.executeUpdate("SET TRANSACTION READ ONLY"); st.executeUpdate("SET TRANSACTION DEFERRABLE"); //Once the first query is executed, transacion level is immutable ResultSet fakeRS = st.executeQuery("SELECT 1"); fakeRS.close(); try (ResultSet rs = st.executeQuery(query)) { return new SqlWindow(rs, getDatabaseInterface().getValueToJooqConverterProvider(), getDatabaseInterface().getValueToJooqDataTypeProvider(), getDatabaseInterface().getScalarTypeToSqlType()); } } catch (SQLException ex) { //TODO: Change exception throw new UserToroException(ex); } } finally { getJooqConf().connectionProvider().release(connection); } }
@SuppressFBWarnings( value = "SQL_NONCONSTANT_STRING_PASSED_TO_EXECUTE", justification = "It is known that this command is unsafe. We need" + "to improve it as soon as we can") @Override public Iterator<ValueRow<ScalarValue<?>>> select(String query) throws UserToroException { Connection connection = getJooqConf().connectionProvider().acquire(); try { try (Statement st = connection.createStatement()) { //This is executed to force read only executions st.executeUpdate("SET TRANSACTION ISOLATION LEVEL SERIALIZABLE"); st.executeUpdate("SET TRANSACTION READ ONLY"); st.executeUpdate("SET TRANSACTION DEFERRABLE"); //Once the first query is executed, transacion level is immutable ResultSet fakeRS = st.executeQuery("SELECT 1"); fakeRS.close(); try (ResultSet rs = st.executeQuery(query)) { return new SqlWindow(rs, getDatabaseInterface().getValueToJooqConverterProvider(), getDatabaseInterface().getValueToJooqDataTypeProvider(), getDatabaseInterface().getScalarTypeToSqlType()); } } catch (SQLException ex) { //TODO: Change exception throw new UserToroException(ex); } } finally { getJooqConf().connectionProvider().release(connection); } }
@SuppressFBWarnings( value = "SQL_NONCONSTANT_STRING_PASSED_TO_EXECUTE", justification = "It is known that this command is unsafe. We need" + "to improve it as soon as we can") @Override public Iterator<ValueRow<ScalarValue<?>>> select(String query) throws UserToroException { Connection connection = getJooqConf().connectionProvider().acquire(); try { try (Statement st = connection.createStatement()) { //TODO: MySQL wine about a java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed. // This is due to a check in mysql driver that check first statement character is 'S' but we are also using CALL // This should be fixed in the driver. Please fill a bug at http://bugs.mysql.com. //st.executeUpdate("SET TRANSACTION READ ONLY"); ResultSet fakeRS = st.executeQuery("SELECT 1"); fakeRS.close(); try (ResultSet rs = st.executeQuery(query)) { return new SqlWindow(rs, getDatabaseInterface().getValueToJooqConverterProvider(), getDatabaseInterface().getValueToJooqDataTypeProvider(), getDatabaseInterface().getScalarTypeToSqlType()); } } catch (SQLException ex) { //TODO: Change exception throw new UserToroException(ex); } } finally { getJooqConf().connectionProvider().release(connection); } }