jdbc ucanaccesssqlexception ucaexc ::: 4.0 4 unexpected token: DOCTOR

此生再无相见时 提交于 2019-12-02 23:37:41

问题


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);       
   }        

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


回答1:


I assume:

  1. you are using JPA
  2. you set delimited-identifiers
  3. you also are using EclipseLink as implementation.

If so, do as follows:

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


来源:https://stackoverflow.com/questions/56379433/jdbc-ucanaccesssqlexception-ucaexc-4-0-4-unexpected-token-doctor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!