de.hs_rm.cs.lecturenotes.server.core.persistence
Class SQLConnection

java.lang.Object
  extended by de.hs_rm.cs.lecturenotes.server.core.persistence.SQLConnection
Direct Known Subclasses:
LectureSelectHandler

public class SQLConnection
extends java.lang.Object

Originates from former class SQLConnection. This class represents an utility class for JDBC SQL connections. This class makes the connection to the database and provides common methods for handling the JDBC driver.

Version:
$LastChangedRevision: 274 $
Author:
Enrico Homann

Field Summary
static int CHECK_DATABASE_TIMEOUT_SECONDS
          Database Timeout check interval.
static java.lang.String DRIVER
          JDBC driver.
static java.lang.String JDBC_HOST_ENDPOINT
          Endpoint for the JDBC Host (host and port).
static java.lang.String JDBC_URI
          URI for the database.
static java.lang.String PASSWORD
          Database user password.
static java.lang.String USER
          Database user name.
 
Constructor Summary
SQLConnection()
           
 
Method Summary
 void connect()
          Connects the JDBC to the SQL DBMS.
 void disconnect()
          Disconnect the JDBC from the SQL DBMS.
 int executeCreateSQL(java.lang.String sqlStmt)
          Executes a given SQL create statement and returns the id of the inserted row.
 int executeUpdateSQL(java.lang.String sqlStmt)
          Executes a given SQL update statement and returns the number of updated rows.
 java.sql.Connection getConnection()
          Will return the JDBC connection.
 boolean isConnected()
          Check whether connection is available or not.
 void setConnection(java.sql.Connection con)
          Sets the SQL connection.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHECK_DATABASE_TIMEOUT_SECONDS

public static final int CHECK_DATABASE_TIMEOUT_SECONDS
Database Timeout check interval.

See Also:
Constant Field Values

JDBC_HOST_ENDPOINT

public static final java.lang.String JDBC_HOST_ENDPOINT
Endpoint for the JDBC Host (host and port).

See Also:
Constant Field Values

JDBC_URI

public static final java.lang.String JDBC_URI
URI for the database.

See Also:
Constant Field Values

USER

public static final java.lang.String USER
Database user name.

See Also:
Constant Field Values

PASSWORD

public static final java.lang.String PASSWORD
Database user password.

See Also:
Constant Field Values

DRIVER

public static final java.lang.String DRIVER
JDBC driver.

See Also:
Constant Field Values
Constructor Detail

SQLConnection

public SQLConnection()
Method Detail

getConnection

public final java.sql.Connection getConnection()
Will return the JDBC connection.

Returns:
Connection.

setConnection

public final void setConnection(java.sql.Connection con)
Sets the SQL connection.

Parameters:
con - Connection

isConnected

public final boolean isConnected()
Check whether connection is available or not.

Returns:
boolean, where true indicates a current connection and false indicates no current connection

connect

public final void connect()
Connects the JDBC to the SQL DBMS.


disconnect

public final void disconnect()
Disconnect the JDBC from the SQL DBMS.


executeCreateSQL

public final int executeCreateSQL(java.lang.String sqlStmt)
Executes a given SQL create statement and returns the id of the inserted row.

Parameters:
sqlStmt - String as SQL statement
Returns:
int last inserted primary key

executeUpdateSQL

public final int executeUpdateSQL(java.lang.String sqlStmt)
Executes a given SQL update statement and returns the number of updated rows.

Parameters:
sqlStmt - String as SQL statement
Returns:
updateCount contains the number of updated rows