[英]JDBC connectivity persistence issue
I understand that jdbc involved these steps 我了解jdbc涉及以下步骤
I have 2 java files one is for GUI (Swing) and another is normal Java file. 我有2个Java文件,一个用于GUI(Swing),另一个是普通的Java文件。 I have many input fields in GUI and send them to backend file for processing using JDBC.
我在GUI中有很多输入字段,并将它们发送到后端文件以使用JDBC进行处理。 I have many methods like this in my Java file.
我的Java文件中有很多这样的方法。 The problem is in each method I have to the entire steps (mentioned above) in each of these methods.
问题在于每种方法中的每种方法的整个步骤(上述)。 As a result of this it has become slow.
结果,它变得缓慢。 I wanted to optimize it making first 3 steps and final steps mentioned above only once.
我想对其进行优化,使上面提到的前3个步骤和最终步骤仅一次。
How to achieve this? 如何实现呢?
Sounds like you need a Connection Pool
. 听起来您需要
Connection Pool
。 There are lots of questions related to connection pooling on Stack Overflow - there's even a tag for it! 在Stack Overflow上有很多与连接池有关的问题-甚至还有一个标签!
https://stackoverflow.com/questions/tagged/connection-pooling https://stackoverflow.com/questions/tagged/connection-pooling
In broad outline, here are several approaches, in (roughly) increasing order of complexity: 概括地说,这里有几种方法,以(大约)复杂度递增的顺序:
Stick with what you're doing, abstracting useful utilities as you learn. 坚持自己的工作,在学习过程中抽象出有用的实用程序。 It's laborious, but it allows maximal cutomization.
这很费力,但可以最大程度地定制。
Adopt a lightweight JDBC helper library; 采用轻量级的JDBC帮助程序库; several are cited here .
这里引用了几个。
Dive in and learn the Java Persistence API . 深入学习Java Persistence API 。
It's entirely possible to do the first while exploring the second or third. 探索第二个或第三个完全有可能做第一个。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.