Ok so my code looks like this
String sqlString = "INSERT into auditlog(report_name, username, start_datetime, resource_uri, resource_id) VALUES (?,?,?,?,?)"; preparedStatement = connection.prepareStatement(sqlString); preparedStatement.setString(1, reportName); preparedStatement.setString(2, username); preparedStatement.setTimestamp(3, new Timestamp(System.currentTimeMillis())); preparedStatement.setString(4, uri); preparedStatement.setBigDecimal(5, new BigDecimal(0)); preparedStatement.executeUpdate(); The table has one more field "ID", but that gets auto generated, how do I get that key ? I need to use it as a Foreign Key in the next bit of my code
SELECT ID FROM YourTable?SELECT MAX(ID) FROM YourTable