jdbcTemplate.update冻结 [英] jdbcTemplate.update freezes

查看:187
本文介绍了jdbcTemplate.update冻结的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用不带"transactionManager"的Spring JdbcTemplate,因为我大多选择这样做.

I'm using a Spring JdbcTemplate without a "transactionManager" since I have mostly select to do.

当我尝试从JUnit调用选择查询时,它可以工作,但是当我尝试调用更新"时,它冻结测试(没有连接超时,什么也没有,只是在等待).

When I try to call select queries from JUnit, it works, but when I try to call an "update", it freezes the test (no connection timeout, nothing, just waiting).

我看过没有任何transactionManager的jdbcTemplates插入/更新示例,但这可能是这里的问题吗?

I've seen examples of jdbcTemplates insert/update without any transactionManager, but could it be the problem here ?

  public void insert(String param1, String param2) {

    String sql = "UPDATE MYTABLE SET name = :param1 where first_name = :param2";

    NamedParameterJdbcTemplate npJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
    SqlParameterSource namedParameters = new MapSqlParameterSource().addValue("param1", param1).addValue("param2", param2);

    npJdbcTemplate.update(sql, namedParameters);
  }

推荐答案

这里的问题是我在SQL客户端(Oracle SQL开发人员)的同一行上传递了相同的更新查询,但尚未在此客户端中提交

The problem here was I had passed the same update query on the same line in a SQL client (Oracle SQL developer) but it had not been committed in this client.

我的JUnit已停滞了12个小时,在我向SQL开发人员提交查询后,更新立即发生在JUnit中.

My JUnit had been stalled for 12 hours and right after I commit the query in SQL developer, the update occurred in the JUnit.

与应用程序中的事务管理或数据源的自动提交状态无关.

It had nothing to do with transaction management in the app or autocommit status of the datasource.

这篇关于jdbcTemplate.update冻结的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆