我正在尝试创建一个将从Net-bean本地运行的简单应用程序,但每次我尝试执行数据库操作时都会出错。
[EL Info]:2015-10-25 09:48:21.192 - ServerSession(26304643) - EclipseLink,版本:Eclipse Persistence Services - 2.3.2.v20111125-r10461 [EL Severe]:2015-10-25 09:48:23.42 - ServerSession(26304643) - 例外[EclipseLink-4002](Eclipse Persistence Services - 2.3.2.v20111125-r10461):org.eclipse.persistence.exceptions .DatabaseException 线程“AWT-EventQueue-0”中的异常javax.persistence.PersistenceException:Exception [EclipseLink-4002](Eclipse Persistence Services - 2.3.2.v20111125-r10461):org.eclipse.persistence.exceptions.DatabaseException 内部异常:java.sql.SQLNonTransientConnectionException:java.net.ConnectException:在端口1527上连接到服务器localhost时出错,并显示消息Connection refused:connect。 错误代码:40000 内部异常:java.sql.SQLNonTransientConnectionException:java.net.ConnectException:在端口1527上连接到服务器localhost时出错,并显示消息Connection refused:connect。
我只是在这种情况下执行一个简单的查询
private void btnSelectLastActionPerformed(java.awt.event.ActionEvent evt) {
String last = JOptionPane.showInputDialog(null, "Please enter the student's last name");
Query q = GeoBeeAppPUEntityManager.createQuery("SELCT t FROM tblStudentsList WHERE t.lastname = ?1 ORDER BY t.firstname");
q.setParameter(1,last );
List<Tblstudents> LastList = q.getResultList();
tblstudentsList2.clear();
tblstudentsList2.addAll(LastList);
这就是持久性xml:
?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="GeoBeeAppPU" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>org.me.mybackgroundapp.Tblstudents</class>
<class>org.me.mybackgroundapp.Tblstudentscores</class>
<class>org.me.mybackgroundapp.Tblquizquestions</class>
<class>org.me.mybackgroundapp.Tblteachers</class>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:derby://localhost:1527/GeoBee_DB"/>
<property name="javax.persistence.jdbc.password" value=""/>
<property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.ClientDriver"/>
<property name="javax.persistence.jdbc.user" value=""/>
</properties>