I have this query below. I've checked it in ms access and it works fine. But when I add it to my program, A "Syntax error in FROM clause." appears. Any suggestions on how to resolve this?
String query ="TRANSFORM COUNT(a.present)\n" +
"SELECT e.ID,e.firstName,e.lastName,e.position,e.rate\n" +
"FROM employees e \n" +
"INNER JOIN attendance a \n" +
"ON e.ID = a.empID \n" +
"GROUP BY e.ID,e.firstName,e.lastName,e.position,e.rate \n" +
"PIVOT a.dateAttended";
this is the full method where the query belongs. The connectToDB method is used to insert the result set to a jtable. Are jtables able to insert pivot queries?
private void attendanceView() throws ClassNotFoundException{
try{
String query ="TRANSFORM COUNT(a.present) " +
"SELECT e.ID,e.firstName,e.lastName,e.position,e.rate " +
"FROM employees e " +
"INNER JOIN attendance a " +
"ON e.ID = a.empID " +
"GROUP BY e.ID,e.firstName,e.lastName,e.position,e.rate " +
"PIVOT a.dateAttended";
Object[][] result = connectToDB(query);
System.out.print(result);
monthlyAttendanceTable.setModel(new javax.swing.table.DefaultTableModel(
result, new String [] {"Employee ID","First Name","Last Name", "Position", "Rate","",""}
)
{
Class[] types = new Class [] {
java.lang.Integer.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.Integer.class,java.lang.Integer.class,java.lang.Integer.class,java.lang.String.class
};
boolean[] canEdit = new boolean [] {
false, false, false, false, false, false, false, false, false,false
};
public Class getColumnClass(int columnIndex) {
return types [columnIndex];
}
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit [columnIndex];
}
});
}catch (ClassNotFoundException ex) {
Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
ex.printStackTrace();
}
}