java executeupdate,Java线程安全中的executeUpdate方法[通俗易懂]

java executeupdate,Java线程安全中的executeUpdate方法[通俗易懂]IhavemultiplethreadstryingtoupdateaMySQLdatabase?isexecuteUpdatemethodthread-safetouse?解决方案No,itisnotthread-safetouse.Infact,ifsomeotherthreadusesastatement,andthenanot…

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE稳定放心使用

java executeupdate,Java线程安全中的executeUpdate方法[通俗易懂]

I have multiple threads trying to update a MySQL database? is executeUpdate method thread-safe to use?

解决方案

No, it is not thread-safe to use.

In fact, if some other thread uses a statement, and then another thread calls executeUpdate(), then the other thread’s ResultSets, if any, will be closed. JavaDoc for java.sql.Statement (of which PreparedStatement is a subtype) “All execution methods in the Statement interface implicitly close a statment’s current ResultSet object if an open one exists.”

Furthermore, it’s unlikely that a given implementation of executeUpdate() would be written to be mulit-thread safe.

You should either syncrhonize all use of the statement and resulting result sets, or make multiple connections so that each thread uses its own JDBC Connection to the database.. I would recommend the latter.

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/179940.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • Java开发人员必须掌握的Linux命令-学以致用(五)

    子曰:“工欲善其事,必先利其器。“做一个积极的人编码、改bug、提升自己我有一个乐园,面向编程,春暖花开!学习应该是快乐的,在这个乐园中我努力让自己能用简洁易懂(搞笑有趣)的表达来讲解让知识或者技术,让学习之旅充满乐趣,这就是写博文的初心。今天是周末,首先祝大家周末愉快了,分享一张今天早上去外面拍的照片:图书馆外面的小公园的春意。这周整理了Linux的命令,也被我称为Linux…

    2022年2月28日
    39
  • python-Numpy学习之(一)ndim、shape、dtype、astype的用法

    python-Numpy学习之(一)ndim、shape、dtype、astype的用法python-Numpy学习之(一)ndim、shape、dtype、astype的用法参考网址:https://blog.csdn.net/Da_wan/article/details/80518725本文介绍numpy数组中这四个方法的区别ndim、shape、dtype、astype。1.ndimndim返回的是数组的维度,返回的只有一个数,该数即表示数组的维度。2….

    2022年6月14日
    27
  • CNN卷积神经网络及图像识别

    CNN卷积神经网络及图像识别CNN卷积神经网络及图像识别前言神经网络(neualnetworks)是人工智能研究领域的一部分,当前最流行的神经网络是深度卷积神经网络(deepconvolutionalneuralnetworks,CNNs),虽然卷积网络也存在浅层结构,但是因为准确度和表现力等原因很少使用。目前提到CNNs和卷积神经网络,学术界和工业界不再进行特意区分,一般都指深层结构的卷积神经网络,层数从”几层“到”几十上百“不定。CNNs目前在很多很多研究领域取得了巨大的成功,例如:语音识别,图像识别,图像分割,

    2022年6月6日
    32
  • mysql源码包安装以及主从搭建

    mysql源码包安装以及主从搭建

    2021年9月3日
    54
  • nginx rtmp 视频流服务器直播测试

    nginx rtmp 视频流服务器直播测试一、配置1、nginx流媒体服务器下载nginx源码,nginx-rtmp-module源码,先configure“–add-modeule=…”…,再编译安装,教程很多,略……。先增加如下配置.再配置路由器端口映射:二、VLC测试Ffmpeg推流转发rtmp://live.hkstv.hk.lxdns.com/live/hks视…

    2022年10月20日
    0
  • IJ实现侧边栏单独搜索

    IJ实现侧边栏单独搜索第一步任意点击一个第二步输入要搜索的单词

    2022年6月27日
    23

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号