This library allows for making basic queries and updates to a database on the fly. It is extremely easy and simple to use.
Below are the very basics on how to use the library.
MySQL database = new MySQL("localhost", "3306", "database", "username", "password");
if (database.connect()) {
//Do something here
}
String select = database.select(Arrays.asList("username", "password"), "Accounts", "email");
MySQLResponse response = database.executeQuery(select, "me@virajprakash.com");
response.closeAll();
This would run the following query:
SELECT username, password FROM Accounts WHERE email = "me@virajprakash.com";
String insert = database.insert("Accounts", 3);
MySQLResponse response = database.executeUpdate(insert, "me@virajprakash.com", "Viraj", "password");
response.closeAll();
This would run the following query:
INSERT INTO Accounts VALUES ("me@virajprakash.com", "Viraj", "password");
String update = database.update("Accounts", Arrays.asList("email", "password"), "username");
MySQLResponse response = database.executeUpdate(update, "me@virajprakash.com", "password123", "Viraj");
response.closeAll();
This would run the following query:
UPDATE Accounts SET email = "me@virajprakash.com", password = "password123" WHERE username = "Viraj";
String count = database.count("Accounts", "Email");
MySQLResponse response = database.executeQuery(count, "me@virajprakash.com");
int result = database.getCount(response);
response.closeAll();
This would run the following query:
SELECT COUNT(*) AS count FROM Accounts WHERE Email = "me@virajprakash.com";