Skip to content

Perform queries using java.sql with one line of code

License

Notifications You must be signed in to change notification settings

ugnich/OneLineSQL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OneLineSQL

Perform queries using java.sql with one line of code.

Examples

boolean userExist = OneLineSQL.getBoolean(mysql, "SELECT 1 FROM users WHERE name=? AND age=?", "Alex", 21);
int age = OneLineSQL.getInt(mysql, "SELECT age FROM users WHERE user_id=?", 1234);
Integer age = OneLineSQL.getInteger(mysql, "SELECT age FROM users WHERE user_id=?", 1234);
Long uts = OneLineSQL.getLong(mysql, "SELECT uts FROM users WHERE user_id=?", 1234);
String name = OneLineSQL.getString(mysql, "SELECT name FROM users WHERE user_id=?", 1234);

ArrayList<Integer> userIDs = OneLineSQL.getArrayInteger(mysql, "SELECT user_id FROM users WHERE age=?", 21);
ArrayList<String> userNames = OneLineSQL.getArrayString(mysql, "SELECT name FROM users WHERE age=?", 21);

OneLineSQL.execute(mysql, "DELETE FROM users WHERE age=?", 21);
int userID = OneLineSQL.insertAutoIncrement(mysql, "INSERT INTO users(name,age) VALUES (?,?)", "Alex", 21);

HashMap<String, Object> data = new HashMap<>();
data.put("name", "Alex");
data.put("age", 21);
boolean success = OneLineSQL.insert(mysql, "users", data);

int userID = OneLineSQL.insertAutoIncrement(mysql, "users", data);

Limitations

For query parameters can use only Integer, Long, Boolean, and String.

About

Perform queries using java.sql with one line of code

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages