0

I tried to transfer certain data to another table but it gives an error, how to fix this code?

This is the code:

System.out.print("Enter name of book: ");
String name_book = main.next();
System.out.print("Enter the author of book: ");
String author_book = main.next();
try {
    ResultSet res = statement.executeQuery("INSERT INTO favorite (name, author, year) SELECT name, author, year FROM books WHERE name='" + name_book + " AND author='" + author_book + "'");
    reader_menu(main);
} catch (SQLException e) {
    e.printStackTrace();
}

Throws this error:

java.sql.SQLException: Can not issue data manipulation statements with executeQuery().
marsel
  • 1
  • 1

0 Answers0