public class DBConnection
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
class |
DBConnection.Error
This inner class handles the Errors which can occur during the SQL-Interactions
|
Constructor and Description |
---|
DBConnection()
Constructor for the database connection.
|
DBConnection(java.lang.String dbHost,
java.lang.String dbName,
java.lang.String dbUser,
java.lang.String dbPswd)
Constructor for the database connection.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Integer |
dbBool2Integer(boolean booleanValue)
This method converts an DB-boolean to an Java-Integer
|
boolean |
dbInteger2Bool(java.lang.Integer intValue)
This method converts an DB-Integer to a Java-boolean
|
com.mysql.jdbc.Connection |
getConnection()
Gets the connection instance to the database.
|
DBConnection.Error |
getError()
Returns the current
DBConnection.Error instance that contains help functions for describing actual problems. |
com.mysql.jdbc.Statement |
getNewStatement()
This method returns a new Statement-Object for a further
handling of SQL-Interaction (e. g. for an executeUpdate)
|
int |
getRowCount(java.sql.ResultSet rs)
This method returns the number of rows from a ResultSet-Object
|
boolean |
getSqlExecuteUpdate(java.lang.String sqlStatement)
This Method executes a SQL-Statement (Create, Insert, Update) in
the database and returns true if this was successful
|
java.sql.ResultSet |
getSqlResult4ExecuteQuery(java.lang.String sqlStmt)
Returns a ResultSet - Object for a SQL-Statement
|
java.sql.ResultSet |
getSqlResult4ExecuteQuery(java.lang.String sqlStmt,
boolean showErrorDialog)
Returns a ResultSet - Object for a SQL-Statement.
|
boolean |
hasErrors()
Indicates that there are errors while interacting with the configured database.
|
boolean |
isValidConnection()
Checks if the connection is (still) valid.
|
void |
setConnection(com.mysql.jdbc.Connection connection)
Sets the connection instance to the database.
|
public DBConnection()
public DBConnection(java.lang.String dbHost, java.lang.String dbName, java.lang.String dbUser, java.lang.String dbPswd)
dbHost
- the database host to usedbName
- the database name to usedbUser
- the database user to usedbPswd
- the database password to usepublic boolean isValidConnection()
public boolean getSqlExecuteUpdate(java.lang.String sqlStatement)
sqlStatement
- the SQL-Statement to executepublic int getRowCount(java.sql.ResultSet rs)
rs
- public java.sql.ResultSet getSqlResult4ExecuteQuery(java.lang.String sqlStmt)
sqlStmt
- the SQL statementpublic java.sql.ResultSet getSqlResult4ExecuteQuery(java.lang.String sqlStmt, boolean showErrorDialog)
sqlStmt
- the SQL statementshowErrorDialog
- the show error dialogpublic com.mysql.jdbc.Statement getNewStatement()
public com.mysql.jdbc.Connection getConnection()
public void setConnection(com.mysql.jdbc.Connection connection)
connection
- the connection to setpublic boolean hasErrors()
public DBConnection.Error getError()
DBConnection.Error
instance that contains help functions for describing actual problems.public boolean dbInteger2Bool(java.lang.Integer intValue)
intValue
- public java.lang.Integer dbBool2Integer(boolean booleanValue)
booleanValue
-