|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsemorg.sql.access.DBAccess
public class DBAccess
Implements the access to the database. Therefor this class fulfills the following functions:
Statement
s and PreparedStatement
s
such that the application can communicate with the database.
Field Summary | |
---|---|
private static String |
chosenDataBaseDriver
|
private static String |
chosenDriverURL
|
private Connection |
connection
|
private static String |
databaseName
|
private static String |
databasePassword
|
private static String |
databaseUsername
|
static DBAccess |
dbAccess
Provides a static db access. |
private static String |
mysqlURL
|
Constructor Summary | |
---|---|
private |
DBAccess()
This method tries to connect to the catalog husemorg and if that fails it tries to create it. |
Method Summary | |
---|---|
private void |
createDatabaseAndConnect()
Creates a connection to the MySQL database and creates the catalog for the application if it does not exist. |
private void |
createTables()
|
PreparedStatement |
getPreparedStatement(String sqlString)
Returns for a given SQL query as a string the appropriate PreparedStatement instance. |
Statement |
getStatement()
Returns for a given SQL query as a string the appropriate Statement instance. |
static void |
init()
Initiates the static database access attribute dbAccess . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static DBAccess dbAccess
private static String chosenDataBaseDriver
private static String chosenDriverURL
private static String databaseName
private static String mysqlURL
private static String databaseUsername
private static String databasePassword
private Connection connection
Constructor Detail |
---|
private DBAccess() throws SQLException, ClassNotFoundException
SQLException
- if the connection to the database can not be created or
the creating of the catalog and the tables fails.
ClassNotFoundException
- if the database driver can not be loaded.createDatabaseAndConnect()
Method Detail |
---|
private void createDatabaseAndConnect() throws SQLException
SQLException
- if the creation, execution or closing of the
Statement
fails.private void createTables() throws SQLException
SQLException
public static void init() throws ClassNotFoundException, SQLException
dbAccess
.
ClassNotFoundException
SQLException
public PreparedStatement getPreparedStatement(String sqlString) throws SQLException
PreparedStatement
instance.
sqlString
- the SQL query as a String
.
SQLException
public Statement getStatement() throws SQLException
Statement
instance.
SQLException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |