viktorstrate/JavaMysqlMadeEasy

A MySQL java library that makes mysql way easier

★ 1Forks 0JavaGitHub ↗Compare

README

JavaMysqlMadeEasy

MySQL in Java made easy, a java API inspired by the way PHP handles mysql.
You just need one .jar file, it includes the drivers needed to run MYSQL in java.
Download latest version

How it works

Connects to the database at the host "localhost" with the username "root" and no password.

Mysql testMysql = new Mysql("localhost", "root", "");

Gets the results from a basic SELECT query

ResultSet result = testMysql.query("SELECT * FROM database.table");

Lists out all the usernames for the table

try {
    while(result.next())
        System.out.println(result.getString("username"));
} catch (SQLException e) {
    e.printStackTrace();
}

Inserts into the table a username and a password, with the username john and password 1234

testMysql.query("INSERT INTO database.table (username, password) VALUES ('john', '1234')");

Updates the table, sets the username for row 1 to bob

testMysql.query("UPDATE database.table SET username='bob' WHERE id = 1");

The database structure for the example above

idusernamepassword
1bob1234
2john1234
3john1234

How to setup

  1. Download the .jar from here.
  2. Add the .jar to your buildpath, see the wiki on how to do that.
  3. here you can see an example file to help or test if it works.
  4. You can find the javadoc here Javadoc

See the wiki for more information.

Contributors

viktorstrate

Issues