public class DbHelper
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
database
The database.
|
private java.sql.Connection |
dBconnection
The d bconnection.
|
private java.lang.String |
driver
The driver.
|
private java.lang.String |
host
The host.
|
private java.lang.String |
password
The password.
|
private java.sql.ResultSet |
resultSet
The result set.
|
private java.sql.Statement |
statement
The statement.
|
private java.lang.String |
user
The user.
|
Constructor and Description |
---|
DbHelper() |
Modifier and Type | Method and Description |
---|---|
void |
closeStatement()
close the current statement if it is open.
|
void |
connect(java.lang.String host,
java.lang.String database,
java.lang.String driver,
java.lang.String user,
java.lang.String password)
connect to database using specified parameters.
|
void |
disconnect()
Disconnect from database and clean up.
|
java.sql.Connection |
getConnection()
Gets the connection.
|
java.sql.ResultSet |
runRawSQL(java.lang.String stmt)
Run an unchecked sql command.
|
private java.lang.String host
private java.lang.String database
private java.lang.String driver
private java.lang.String user
private java.lang.String password
private java.sql.Connection dBconnection
private java.sql.Statement statement
private java.sql.ResultSet resultSet
public void connect(java.lang.String host, java.lang.String database, java.lang.String driver, java.lang.String user, java.lang.String password) throws java.lang.Exception
host
- the hostdatabase
- the databasedriver
- the driveruser
- the userpassword
- the passwordjava.lang.Exception
- the exceptionpublic void disconnect()
public java.sql.ResultSet runRawSQL(java.lang.String stmt) throws java.lang.Exception
stmt
- the stmtjava.lang.Exception
- the exceptionpublic java.sql.Connection getConnection()
public void closeStatement() throws java.sql.SQLException
java.sql.SQLException
- the SQL exception