gpt4 book ai didi

java - 从 netbeans 运行应用程序和运行 jar 有什么区别?

转载 作者:行者123 更新时间:2023-11-30 11:50:36 28 4
gpt4 key购买 nike

我有一个从 Netbeans 7.1 运行时完美运行的 java 应用程序,但如果我使用构建 jar,它会崩溃。

我一直在调查这个问题,我注意到应用程序暂停调用 DriverManager.getConnection()。

我正在做类似的事情:

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); 
Connection con = DriverManager.getConnection("jdbc:sqlserver://127.0.0.1:2304;user=username;password=12345;database=databasename");

我也尝试过 jtds,但结果相同。

我运行的是 Windows 7 家庭高级版SQL Server 2008(本地主机)Netbeans 7.1(从 Netbeans 运行时应用程序工作正常)Java 版本 1.6

线程转储

java.lang.Exception: Stack trace
at java.lang.Thread.dumpStack(Unknown Source)
at joomlasyncrnzr.JoomlaSyncrnzrApp.getCon(JoomlaSyncrnzrApp.java:314)
at joomlasyncrnzr.JoomlaSyncrnzrApp.taxas(JoomlaSyncrnzrApp.java:604)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.jdesktop.application.ApplicationAction.noProxyActionPerformed(Ap
licationAction.java:662)
at org.jdesktop.application.ApplicationAction.actionPerformed(ApplicatinAction.java:698)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

这可能是什么原因造成的?

最佳答案

我遇到了 DriverManager.getConnection 调用的同样问题,只是无限期挂起。

为我解决问题的方法是回到 Java 6 Update 25。Update 29 似乎引入了一个与 SQL Server 的 JDBC 连接的错误。我认为 Update 27(或更早版本)仍然可以正常工作。

关于java - 从 netbeans 运行应用程序和运行 jar 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7892843/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com