我建立了一个简单的应用程序,连接使用 Java Persistence、实体管理器绑定 jTable 的 Derby 数据库(Netbeans)。问题是当我在其他系统上运行 .jar 文件时,它无法执行。有人能告诉我这是为什么吗?
在其他系统上运行它时出现错误:
C:\>java -jar persist.jar
[EL Info]: 2013-01-08 17:06:45.715--ServerSession(4597467)--EclipseLink, version
: Eclipse Persistence Services - 2.3.2.v20111125-r10461
[EL Severe]: 2013-01-08 17:06:48.24--ServerSession(4597467)--Exception [EclipseL
ink-4002] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.p
ersistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLNonTransientConnectionException: java.net.Connec
tException : Error connecting to server localhost on port 1527 with message Conn
ection refused: connect.
Error Code: 40000
Exception in thread "AWT-EventQueue-0" javax.persistence.PersistenceException: E
xception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.2.v20111125-r104
61): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLNonTransientConnectionException: java.net.Connec
tException : Error connecting to server localhost on port 1527 with message Conn
ection refused: connect.
Error Code: 40000
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(En
tityManagerSetupImpl.java:517)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.get
DatabaseSession(EntityManagerFactoryDelegate.java:188)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.cre
ateEntityManagerImpl(EntityManagerFactoryDelegate.java:277)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createE
ntityManagerImpl(EntityManagerFactoryImpl.java:294)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createE
ntityManager(EntityManagerFactoryImpl.java:272)
at persist.NewJFrame.initComponents(NewJFrame.java:30)
at persist.NewJFrame.<init>(NewJFrame.java:17)
at persist.NewJFrame$1.run(NewJFrame.java:101)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour
ce)
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)
Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.2.v2
0111125-r10461): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLNonTransientConnectionException: java.net.Connec
tException : Error connecting to server localhost on port 1527 with message Conn
ection refused: connect.
Error Code: 40000
at org.eclipse.persistence.exceptions.DatabaseException.sqlException(Dat
abaseException.java:324)
at org.eclipse.persistence.exceptions.DatabaseException.sqlException(Dat
abaseException.java:319)
at org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConn
ector.java:138)
at org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(
DatasourceLogin.java:162)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAn
dDetectDatasource(DatabaseSessionImpl.java:584)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.log
in(EntityManagerFactoryProvider.java:206)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(En
tityManagerSetupImpl.java:488)
... 21 more
Caused by: java.sql.SQLNonTransientConnectionException: java.net.ConnectExceptio
n : Error connecting to server localhost on port 1527 with message Connection re
fused: connect.
at org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(Unkn
own Source)
at org.apache.derby.client.am.SqlException.getSQLException(Unknown Sourc
e)
at org.apache.derby.jdbc.ClientDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConn
ector.java:98)
... 25 more
Caused by: org.apache.derby.client.am.DisconnectException: java.net.ConnectExcep
tion : Error connecting to server localhost on port 1527 with message Connection
refused: connect.
at org.apache.derby.client.net.NetAgent.<init>(Unknown Source)
at org.apache.derby.client.net.NetConnection.newAgent_(Unknown Source)
at org.apache.derby.client.am.Connection.<init>(Unknown Source)
at org.apache.derby.client.net.NetConnection.<init>(Unknown Source)
at org.apache.derby.client.net.NetConnection40.<init>(Unknown Source)
at org.apache.derby.client.net.ClientJDBCObjectFactoryImpl40.newNetConne
ction(Unknown Source)
... 29 more
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at javax.net.DefaultSocketFactory.createSocket(Unknown Source)
at org.apache.derby.client.net.OpenSocketAction.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 35 more
jar
,它使用persist.jar
作为它的依赖关系,对吧? - Less