Utils.MySQL
Class MySQLConnector

java.lang.Object
  extended by Utils.MySQL.MySQLConnector

public class MySQLConnector
extends java.lang.Object

Class allowing the connection to a MySQL database.


Field Summary
protected  java.lang.String db
          The DB name
protected  java.lang.String host
          The name of the computer hosting the DB
protected  java.lang.String port
          The name of the port for the DB connection
protected  java.lang.String pwd
          Password for the DB connection
protected  java.lang.String usr
          Username for the DB connection
 
Constructor Summary
MySQLConnector(java.lang.String host, java.lang.String port, java.lang.String usr, java.lang.String pwd, java.lang.String db)
          Basic constructor.
 
Method Summary
 void close()
          Closes the connection to the DB.
 void connect()
          Connects to the DB.
 MySQLQuery createQuery()
          Creates a new query over this connection.
 java.sql.Statement createStatement()
          Creates a new statement over this connection.
 int update(java.lang.String query)
          Executes an update query over this connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

db

protected java.lang.String db
The DB name


host

protected java.lang.String host
The name of the computer hosting the DB


port

protected java.lang.String port
The name of the port for the DB connection


usr

protected java.lang.String usr
Username for the DB connection


pwd

protected java.lang.String pwd
Password for the DB connection

Constructor Detail

MySQLConnector

public MySQLConnector(java.lang.String host,
                      java.lang.String port,
                      java.lang.String usr,
                      java.lang.String pwd,
                      java.lang.String db)
Basic constructor.

Parameters:
host - Host name for the DB connection.
port - Port name for the DB connection.
usr - Username for the DB connection.
pwd - Password for the DB connection.
db - Name of the db.
Method Detail

connect

public void connect()
Connects to the DB.


close

public void close()
Closes the connection to the DB.


createStatement

public java.sql.Statement createStatement()
                                   throws java.sql.SQLException
Creates a new statement over this connection.

Returns:
A new statement over this connection.
Throws:
java.sql.SQLException

createQuery

public MySQLQuery createQuery()
Creates a new query over this connection.

Returns:
A new query over this connection.

update

public int update(java.lang.String query)
Executes an update query over this connection.

Parameters:
query - The string containing the query to be executed.
Returns:
The result code of the update query.