0

I have the following diagnostic sql statementselect * from MachineShift WHERE ShiftID = 'D' And MachineID='F22'

Originally, I had this: select HoursRunning from MachineShift where ShiftID = 'D' and MachineID = 'F22' and MachineDate = 2014/01/01. However, I got the error of 'too few parameters'. specifically for HoursRunning and MachineDate.

The table: MachinShift (MachineID,ShiftID,OperatorID,HoursRunning,MachineDate)

After using some sample code I found in another stackoverflow question, I managed to figure out that the java program itself is not seeing those two columns (HoursRunning and MachineDate).

Here's the troubleshooting stuff: After using this code: ResultSetMetaData rsmd = rs.getMetaData(); System.out.println(rsmd.getColumnName(1)); System.out.println(rsmd.getColumnName(2)); System.out.println(rsmd.getColumnName(3)); System.out.println(rsmd.getColumnName(4));
System.out.println(rsmd.getColumnName(5));

I got only these 3 columns. MachineID ShiftID OperatorID

Then an error saying 'Invalid Descriptor index' which I assume means that there were no more columns to find.

I've never encountered this sort of error before. The sql statement that I originally wanted to use worked perfectly when I executed it with MS Access, but as soon as I used the java program to retrieve or update data, it could not find these columns. I would also like to add that a month ago, the java program was working fine and it was extracting and updating data from this table as well as others without a problem.

Is this some sort of tabulation problem? I have restarted my pc thinking Access might need to update some sort of registry, but the problem persisted through all that. I've also tried name changes, rebuilding the tables from scratch etc.

  • Which JDBC driver are you using to connect to Access? The JDBC-ODBC bridge driver? Jackcess? UCanAccess? – Luke Woodward Jul 13 '14 at 09:36
  • I used this: conn = DriverManager.getConnection("jdbc:odbc:DRIVER={Microsoft Access Driver (*.mdb, *.accdb) – Savva Pouroullis Jul 13 '14 at 09:46
  • So... The JDBC-ODBC I'm guessing? – Savva Pouroullis Jul 13 '14 at 09:46
  • Yes, that is the JDBC-ODBC bridge driver, which was only intended as a transitional driver, isn't supported by Oracle, has known bugs, and no longer exists in Java 8. I would recommend switching to Jackcess or UCanAccess. I recently came across another question regarding odd behaviour with the JDBC-ODBC bridge driver, and I gave them the same recommendation. – Luke Woodward Jul 13 '14 at 09:50
  • Thanks very much for the recommendation. Would it be possible to provide a link with instructions to use one of these drivers? – Savva Pouroullis Jul 13 '14 at 09:54
  • I've just encountered another problem which might be related to this: I'm entering data into the database using the java program, and it rereads this data from the database without a problem, but the data won't show up in access at all, even after re-opening everything. – Savva Pouroullis Jul 13 '14 at 09:57
  • Firstly, I don't have a copy of Access to test against, so I can't give any recommendations based on experience. Nonetheless, here are some instructions for getting started with UCanAccess: http://stackoverflow.com/q/21955256/. – Luke Woodward Jul 13 '14 at 10:03

0 Answers0