Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Code of connecting
- Code of connecting
- private Connection connection;
- public void mysqlSetup() {
- String host = "us-cdbr-iron-east-01.cleardb.net";
- int port = 3306;
- String database = "null";
- String username = "null";
- String password = "null";
- try {
- synchronized (this) {
- if (getConnection() != null && !getConnection().isClosed()) {
- return;
- }
- Class.forName("com.mysql.cj.jdbc.Driver");
- setConnection(
- DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database, username, password));
- }
- } catch (SQLException | ClassNotFoundException e) {
- e.printStackTrace();
- }
- }
- Code of editing
- Code of editing
- public boolean maintenance() {
- try {
- PreparedStatement statement = getConnection()
- .prepareStatement("SELECT * FROM maintenance WHERE status=?");
- statement.setString(1, "stats");
- ResultSet results = statement.executeQuery();
- results.next();
- int returnvalue = results.getInt("id");
- results.close();
- statement.close();
- return returnvalue != 0;
- } catch (SQLException e) {
- e.printStackTrace();
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement