我正在使用带有Java类的netbeans从Access数据库表中获取数据并将其显示在jtable上。当我按照所有步骤进行操作时,它给了我ucanaccess错误,因为它是net ucanaccess jdbc ucanaccesssqlexception ucaexc ::: 4.0 4个意外的标记:DOCTOR。我在accdb中有两个表,分别称为Patient和Doctor。
我已经做了一切所需的事情。
public void viewAppointment() throws ClassNotFoundException, SQLException{
Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
Connection conn = DriverManager.getConnection("jdbc:ucanaccess://C:/Users/AQ/Documents/NetBeansProjects/MC170402106_2/MC170402106.accdb");
String sql1 = "Select p.Name AS Patient, p.Disesae AS Disease, Doctor.Name AS Doctor"
+ " Doctor.Visiting_Day AS SechduleDay from Patients AS p"
+ " where p.Disease = Doctor.Specialization";
try{
ps = conn.prepareStatement(sql1);
rs = ps.executeQuery();
jTable1.setModel(DbUtils.resultSetToTableModel(rs));
}
catch(Exception e){
JOptionPane.showMessageDialog(null, e);
}
我希望这将从数据库中获取数据并将其显示在jtable上。
答案 0 :(得分:0)
我认为:
delimited-identifiers
如果是,请执行以下操作:
在persistence.xml中包含目标数据库条目:
<property name="eclipselink.target-database" value="org.eclipse.persistence.platform.database.AccessPlatformDelimiterConfig"/>
将新类添加到您的类路径中:
package org.eclipse.persistence.platform.database;
public class AccessPlatformDelimiterConfig extends AccessPlatform {
private static final long serialVersionUID = 7034590043310425678L;
public AccessPlatformDelimiterConfig() {
super();
this.tableQualifier = "";
this.startDelimiter = "";
this.endDelimiter = "";
}
}