public boolean createProject(Project project, int requestId, int userId) throws RemoteException, SQLException { System.out.println(userId); ResultSet result = connection .createStatement() .executeQuery( "select count(*) from logs where requestId = " + requestId + " and userId = " + userId); if (result.getInt(1) == 0) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm"); result = connection .createStatement() .executeQuery("select id from projects where Name = \"" + project.getName() + "\""); if (result.next()) { return false; } connection.setAutoCommit(false); connection .createStatement() .execute( "insert into projects (Name, Deadline, Objective, Description, OwnerUserId,Active) values (\"" + project.getName() + "\", \"" + dateFormat.format(project.getDeadline()) + "\"," + project.getObjective() + ", \"" + project.getDescription() + "\", " + userId + "," + 1 + ")"); result = connection .createStatement() .executeQuery("select id from projects where Name = \"" + project.getName() + "\""); int projectId = result.getInt(1); connection .createStatement() .execute( "insert into administrators (ProjectId, UserId) values (" + projectId + ", " + userId + ")"); connection .createStatement() .execute( "insert into logs (UserId, RequestId, Response) values (" + userId + ", " + requestId + ", 1)"); for (Reward reward : project.getRewards()) { this.createReward(reward, 0, projectId, userId); } for (Path path : project.getPaths()) { this.createPath(path, 0, userId, projectId); } project.setId(projectId); System.out.println("Created Proj"); User username = getUser(userId); if (isTumblr(username.getUsername())) { postinTumblr(username.getUsername(), project); } connection.commit(); return true; } else { System.out.println("OUPS"); result = connection .createStatement() .executeQuery( "select response from logs where requestId = " + requestId + " and userId = " + userId); return result.getBoolean(1); } }