pt.ua.bioinformatics.coeus.api
Class DB

java.lang.Object
  extended by pt.ua.bioinformatics.coeus.api.DB

public class DB
extends java.lang.Object

SQL database connection layer.

Required for SQL-based data imports.
Based on JDBC4, supports any kind of database (as long as respective connector is on /lib).


Constructor Summary
DB()
           
DB(java.lang.String database, java.lang.String connectionString)
          Constructor with custom database information.
 
Method Summary
 boolean close()
          Closes current database connection.
 boolean connect(java.lang.String connectionString)
          Establishes a new connection to the database.
 boolean connectX()
          Establishes a new connection to the database.
 boolean delete(java.lang.String what, java.lang.String query)
          Updates data in the instanced database based on the passed query.
 java.sql.ResultSet getData(java.lang.String query)
          Retrieves data from the instance database.
 boolean insert(java.lang.String what, java.lang.String query)
          Inserts data in the instanced database based on the passed query.
 boolean update(java.lang.String what, java.lang.String query)
          Updates data in the instanced database based on the passed query.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DB

public DB()

DB

public DB(java.lang.String database,
          java.lang.String connectionString)
Constructor with custom database information.

Parameters:
database - The database name
connectionString - The connection string (if distinct from WAVe)
Method Detail

connect

public boolean connect(java.lang.String connectionString)
Establishes a new connection to the database.

Feature:
Performs the required operations to establish a new database connection

Returns:
Success of the operation (true if connects, false if fails to connect)

connectX

public boolean connectX()
Establishes a new connection to the database.

Feature:
Performs the required operations to establish a new database connection to non-default database

Returns:
Success of the operation (true if connects, false if fails to connect)

close

public boolean close()
Closes current database connection.

Feature:
Performs the required operations to close an open database connection

Returns:
Success of the operation (true if it closes the connection, false if it fails to close the connection)

insert

public boolean insert(java.lang.String what,
                      java.lang.String query)
Inserts data in the instanced database based on the passed query.

Feature:
Executes required tests and operations to insert novel data in the database

Parameters:
what - String to describe what is being inserted in the database
query - The insertion query
Returns:
Success of the operation (true if inserts correctly, false if fails to insert)

update

public boolean update(java.lang.String what,
                      java.lang.String query)
Updates data in the instanced database based on the passed query.

Feature:
Executes required tests and operations to update existing data in the database

Parameters:
what - String to describe what is being updated in the database
query - The update query
Returns:
Success of the operation (true if updates correctly, false if fails to update)

delete

public boolean delete(java.lang.String what,
                      java.lang.String query)
Updates data in the instanced database based on the passed query.

Feature:
Executes required tests and operations to update existing data in the database

Parameters:
what - String to describe what is being updated in the database
query - The update query
Returns:
Success of the operation (true if updates correctly, false if fails to update)

getData

public java.sql.ResultSet getData(java.lang.String query)
Retrieves data from the instance database.

Feature:
Retrieves a Result Set table containing the results from the provided SELECT statement

Parameters:
query - SELECT query to get the desired data
Returns:
Result Set containing the output of the executed SELECT statement