Skip to content
This repository was archived by the owner on Jan 13, 2021. It is now read-only.

How to use

Viktor Hundahl Strate edited this page Feb 20, 2015 · 3 revisions

Connecting to a database

To connect to a Mysql database, make an instance of the class Mysql, like so.

Mysql mysql = new Mysql("[HOST]", "[USERNAME]", "[PASSWORD]");
  • Replace [HOST] with the hostname of the database fx. "localhost" or "example.com".
  • Replace [USERNAME] with your username of the database, it's often "root".
  • Replace [PASSWORD] with the password, if you have one else use a blank string.

You can also connect later

Mysql mysql = new Mysql();
mysql.connect("[HOST]", "[USERNAME]", "[PASSWORD]");

Execute queries

To execute a query, type.

mysql.query("[QUERY]");
  • Replace [QUERY] with the query, for some common query examples see the example file here

if you select somthing from the database it will return a ResultSet, to save that information and use it type.

ResultSet result = mysql.query("[QUERY]");

See more about ResultSet's here, or look at the example file for an example on how to get information here.

Clean up

When you are done with the mysql database run this to free up memory.

mysql.close();

Clone this wiki locally