use gitea instead of github

* use gitea instead of github
* use prepareStatement instead of statement
This commit is contained in:
2018-11-16 17:39:38 +01:00
parent a23b87fcb8
commit 5e89faff49
3 changed files with 53 additions and 63 deletions

View File

@ -321,7 +321,6 @@ public class DBController {
* @throws IOException
*/
private void checkAddEntry() throws SQLException, FileNotFoundException, IOException {
Statement stmt = connection.createStatement();
PreparedStatement ps = connection.prepareStatement("insert into films values (?, ?, ?, ?, ?, ?, ?)");
LOGGER.info("checking for entrys to add to DB ...");
@ -334,12 +333,15 @@ public class DBController {
// if file is file and has mime type "video"
if (file.isFile() && mimeType != null && mimeType.contains("video")) {
// get all files (films)
if (!filmsdbStreamURL.contains(file.getPath())) {
stmt.executeUpdate("insert into films values ("
+ "'" + file.getPath() + "',"
+ "'" + cutOffEnd(file.getName()) + "', '', '', 0, 0, 0.0)");
connection.commit();
stmt.close();
if (!filmsdbStreamURL.contains(file.getPath())) {
ps.setString(1, file.getPath());
ps.setString(2, cutOffEnd(file.getName()));
ps.setString(3, "");
ps.setString(4, "");
ps.setInt(5, 0);
ps.setBoolean(6, false);
ps.setDouble(7, 0);
ps.addBatch(); // adds the entry
LOGGER.info("Added \"" + file.getName() + "\" to database");
filmsdbStreamURL.add(file.getPath());
}
@ -350,13 +352,16 @@ public class DBController {
if (season.isDirectory()) {
int ep = 1;
for (File episode : season.listFiles()) {
if (!filmsdbStreamURL.contains(episode.getPath())) {
if (!filmsdbStreamURL.contains(episode.getPath())) {
ps.setString(1, episode.getPath().replace("'", "''"));
ps.setString(2, cutOffEnd(file.getName()));
ps.setString(3, Integer.toString(sn));
ps.setString(4, Integer.toString(ep));
ps.setInt(5, 0);
ps.setBoolean(6, false);
ps.setDouble(7, 0);
ps.addBatch(); // adds the entry
LOGGER.info("Added \"" + file.getName() + "\", Episode: " + episode.getName() + " to database");
stmt.executeUpdate("insert into films values ("
+ "'" + episode.getPath().replace("'", "''") + "',"
+ "'" + cutOffEnd(file.getName()) + "','" + sn + "','" + ep + "', 0, 0, 0.0)");
connection.commit();
stmt.close();
filmsStreamURL.add(episode.getPath());
filmsdbStreamURL.add(episode.getPath());
ep++;