Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try (Connection connection = DriverManager.getConnection("jdbc:mysql://localhost/films?", connInfo);
- PreparedStatement statement = connection.prepareStatement("INSERT INTO films(name_film, rating, description, poster, path, year_of_release) VALUE (?, ?, ?, ?, ?, ?)")) {
- for (File film:films) {
- String actors = new String(Files.readAllBytes(Paths.get(film.getPath() + "/actors.txt")));
- String description = new String(Files.readAllBytes(Paths.get(film.getPath() + "/description.txt")));
- String genres = new String(Files.readAllBytes(Paths.get(film.getPath() + "/genres.txt")));
- String names = new String(Files.readAllBytes(Paths.get(film.getPath() + "/names.txt")));
- String Producer = new String(Files.readAllBytes(Paths.get(film.getPath() + "/Producer.txt")));
- String year = new String(Files.readAllBytes(Paths.get(film.getPath() + "/year.txt")));
- String[] namesArray = names.split(" / ");
- for (int i = 0; i<namesArray.length; i++) {
- namesArray[i] = namesArray[i].trim();
- }
- statement.setString(1, new Gson().toJson(namesArray));
- statement.setInt(2,5);
- statement.setString(3, description);
- statement.setString(4,film.getPath() + "/poster.jpg");
- statement.setString(5, film.getPath() + "filmName");
- statement.setInt(6,Integer.parseInt(year.trim()));
- statement.executeUpdate();
- }//for
- }
- INSERT INTO films(name_film, rating, description, poster, path, year_of_release) VALUE ("world's dog", 5, "Привет мир", "Пока мир", "world's dog", 2017);
Add Comment
Please, Sign In to add comment