I am injecting my database with the JSON file and am trying to get the route_id
from the routes
table after inserting the route and the direction (Also of the inserted direction and route record). I have changed prep.executeUpdate()
to prep.executeQuery()
but I am getting this error:
java.sql.SQLException: Can not issue data manipulation statements with executeQuery(). at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:998) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:937)
Code:
DatabaseMetaData dbm = con.getMetaData();
ResultSet routesTables = dbm.getTables(null, null, "routes", null);
if (routesTables.next()) {
PreparedStatement prep = con
.prepareStatement("INSERT INTO routes(direction, route)"
+ "VALUES( ?, ?)");
prep.setString(1, direction);
prep.setInt(2, route);
ResultSet rs = prep.executeQuery();
}
How can I get the route_id in this case ResultSet rs = prep.executeQuery();
? Currently I am getting the error above.
I appreciate any help.