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.