On this form, words separated by spaces are entered into the Authors and Keywords fields. How to immediately parse 2 arrays and transfer them to the database with one request, if possible?
tried like this:
connection = connector.getConnection(); query = connection.prepareStatement(INSERT INTO document_s (document_id, document_name, document_type, creation_date, parent_id) VALUES(?,?,?,?,?), Statement.RETURN_GENERATED_KEYS); query.setNull(1, Types.INTEGER); query.setString(2, docid.getDoc_name()); query.setString(3, docid.getDoc_type()); query.setString(4, docid.getCreation_date()); query.setInt(5, docid.getParent_id()); query.executeUpdate(); resultSet = query.getGeneratedKeys(); resultSet.next(); int key = resultSet.getInt(1); query1 = connection.prepareStatement(INSERT INTO document_r(index, document_id, authors, keywords) VALUES(?,?,?,?)); query1.setNull(1, Types.INTEGER); query1.setInt(2, key); query1.setString(3, docid.getAuthors()); query1.setString(4, docid.getKeywords()); query1.executeUpdate(); return 0; } catch (SQLException e) { e.printStackTrace(); } finally { connector.close1(connection, query, resultSet); } return 0; I mean what needs to be done through a for loop like this:
for (String retval: s.split(" ")) { query1.setString(1, retval); query1.executeUpdate(); } it needs to be done for two lines at once.
The result should be like this
PS Help

