Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.server.util.database;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.Statement;
- import java.sql.ResultSet;
- /**
- * Handles database actions
- * @author DHAReauxK
- */
- public class Integration {
- /**
- * @note temporary strings
- */
- private String host, database, username, password = "";
- public void connect() throws Exception {
- Class.forName("com.mysql.jdbc.Driver").newInstance ();
- connection = DriverManager.getConnection("jdbc:mysql://" + host + "/" + database + "", username, password);
- statement = connection.createStatement();
- }
- public ResultSet query(String s) {
- try {
- if (s.toLowerCase().startsWith("select")) {
- ResultSet rs = statement.executeQuery(s);
- return rs;
- } else {
- statement.executeUpdate(s);
- }
- return null;
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
- }
- private Connection connection;
- private Statement statement;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement