textclassifier.database
Class MySQLAccess

java.lang.Object
  extended by textclassifier.database.MySQLAccess

public class MySQLAccess
extends java.lang.Object

Class makes connection to the MySQL database, stores necessary information about it and provides function for running SQL queries.


Field Summary
 java.sql.Connection conn
           
 
Constructor Summary
MySQLAccess()
           
MySQLAccess(java.lang.String server, java.lang.String db, java.lang.String user_name, java.lang.String pass)
          Constructor of the class - stores information about database, user etc.
 
Method Summary
 java.sql.Connection getConnection()
          Returns a reference to connection
 boolean isConnected()
          Finds out if the database connection is established
 boolean makeConnection()
          Make a new connection - try to make connection to database.
 java.sql.ResultSet runSqlCommand(java.lang.String command)
          Allows to send an SQL query to the connected MySQL database server
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

conn

public java.sql.Connection conn
Constructor Detail

MySQLAccess

public MySQLAccess()

MySQLAccess

public MySQLAccess(java.lang.String server,
                   java.lang.String db,
                   java.lang.String user_name,
                   java.lang.String pass)
Constructor of the class - stores information about database, user etc.

Parameters:
server - URL of MySQL server where the input table is located
db - Name of a database on a MySQL server
user_name - MySQL Database user
pass - MySQL Database password
Method Detail

makeConnection

public boolean makeConnection()
Make a new connection - try to make connection to database.

Returns:
true if connection process finished succesfully, else return false
Throws:
java.sql.SQLException - SQL Error

getConnection

public java.sql.Connection getConnection()
Returns a reference to connection

Returns:
an instance of Connection class

runSqlCommand

public java.sql.ResultSet runSqlCommand(java.lang.String command)
Allows to send an SQL query to the connected MySQL database server

Parameters:
command - string that contains an SQL command
Returns:
ResultSet as a result of SQL command

isConnected

public boolean isConnected()
Finds out if the database connection is established

Returns:
true, if database is successfully connected