I am trying to insert a row into an MS Access database and it works fine for every other field apart from time.
My code is
public boolean insertLogEntry(LogEntry lg){
PreparedStatement ps = null;
String sql = "INSERT INTO LogEntry ( " +
"IPAddress, " +
"Date, " +
"Request, " +
"FileName, " +
"Status, " +
"Size, " +
"Referrer, " +
"UserAgent, " +
"Website " +
") " +
"VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?)";
try{
ps = connection.prepareStatement(sql);
ps.setString(1, lg.getFromIP().getHostAddress());
ps.setTime(2, new java.sql.Time(lg.getDate().getTime()));
ps.setString(3, lg.getRequest());
ps.setString(4, lg.getFile());
ps.setInt(5, lg.getStatus());
ps.setInt(6, lg.getSize());
ps.setString(7, lg.getReferrer());
ps.setString(8 , lg.getUserAgent());
ps.setString(9 , lg.getWebsite());
ps.executeUpdate();
}catch (SQLException e) {
System.err.println(e.getSQLState());
e.printStackTrace();
}
Java throws the following error -
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.
Any suggestions?
Thanks