本文介绍了jdbc ucanaccesssqlexception ucaexc ::: 4.0 4个意外的令牌:DOCTOR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有Java类的netbeans从Access数据库表中获取数据并将其显示在jtable上.当我按照所有步骤进行操作时,它会给我ucanaccess错误,因为它是net ucanaccess jdbc ucanaccesssqlexception ucaexc ::: 4.0 4个意外的标记:DOCTOR.我在accdb中有两个表,分别称为Patient和Doctor.

I am using netbeans with java classes to fetch data from access database tables and display it on jtable. When I followed all the steps it gives me the ucanaccess error as net ucanaccess jdbc ucanaccesssqlexception ucaexc ::: 4.0 4 unexpected token: DOCTOR. i have two tables in accdb called Patient and Doctor.

我已经完成了一切所需的工作.

I have done everything needed for it.

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上.

I expect that this will take data from database and display it on jtable.

推荐答案

我假设:

  1. 您正在使用JPA
  2. 您设置了delimited-identifiers
  3. 您还使用EclipseLink作为实现.

如果是,请执行以下操作:

If so, do as follows:

在persistence.xml中包含目标数据库条目:

Include a target-database entry in persistence.xml:

    <property name="eclipselink.target-database" value="org.eclipse.persistence.platform.database.AccessPlatformDelimiterConfig"/>

将新类添加到您的类路径中:

Add a new class to your classpath:

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 = "";
    }
}

这篇关于jdbc ucanaccesssqlexception ucaexc ::: 4.0 4个意外的令牌:DOCTOR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 23:06