与 MySQL 连接的 Java 应用程序死了 [英] Java Application connected with MySQL went dead
问题描述
java应用连接mysql http://nowstock.co.kr/p11.png
以上程序是连接到 MySQL 的 Java 应用程序.我可以用它控制我网站的所有文档.删除文档、创建文档和保存文档.无论如何,这个程序是按照本教程制作的:http://www.javaguicodexample.com/javadesktopguimysql1.html
Above program is Java Application connected to MySQL. I can control all the documents of my web site with it. Deleting documents, Creating documents and Saving documents. Anyway, This program was maded followed this tutorial : http://www.javaguicodexample.com/javadesktopguimysql1.html
问题是,当我删除 5~10 个文件时,它很容易删除,没有问题.但是数量超过20,程序就死了.程序停止了.我不能再控制程序了.也许我认为这是一次处理数据的大小问题.我怎么解决这个问题?谢谢.
The problem is, when I delete the 5~10 documents , It is easily deleted with no problem. But the number is over 20, the program went dead. The program stopped. I could't control the program anymore. Maybe I think it is problem of the size of handling datas at once. How can I solve this problem? Thanks.
问题:我不能一次删除超过 20 个文件.当我尝试这个时,程序死了
推荐答案
可能有一百万个原因.您需要分析您的程序并检测瓶颈所在.
There could be a million reason for that. You need to profile your program and detect where the bottleneck is.
例如,初学者的一个常见错误是不使用连接池,因此对于每个事务(删除),都必须创建一个新的数据库连接——这是代价高昂的.
For example, a common beginner's mistake is not using connection pool, hence for each transaction (delete) a new database connection has to be created -- which is costly.
其他常见原因:您没有意识到您的代码使用了多少内存.可能是虚拟机用完了,放弃了.
Other common causes: you did not realize how much memory your code is using. Probably the virtual machine is maxed out and give up.
这也可能是 MySQL 上的吞吐量/锁定问题.
This could also be troughput / locking problem on MySQL.
我建议您学习如何分析 java &MySQL.互联网上应该有很多关于此的文章/教程.
I recommend you learn how to profile java & MySQL. There should be plenty article / tutorials about this in internet.
这篇关于与 MySQL 连接的 Java 应用程序死了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!