|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.stanwood.media.database.AbstractGenericDatabase
org.stanwood.media.database.MysqlDatabase
public class MysqlDatabase
This is a database manager class were the database is connected directly via TCP/IP to a MySQL database.
Constructor Summary | |
---|---|
MysqlDatabase(java.lang.String host,
java.lang.String username,
java.lang.String password,
java.lang.String database)
Used to create a MYSQL database controller class. |
Method Summary | |
---|---|
java.sql.Connection |
createConnection()
This is used to get a connection to the database |
boolean |
dropTable(java.sql.Connection connection,
java.lang.String tableName)
This is called to delete a table from the database |
void |
executeSQL(java.sql.Connection connection,
java.lang.String sql)
This is used to execute a simple SQL statement on the database. |
java.lang.String |
getConnectionUrl()
Used to get the connection url used to connect to the database |
java.sql.PreparedStatement |
getStatement(java.sql.Connection connection,
java.lang.String sql)
This is used to create a PreparedStatement from the give SQL. |
void |
init()
This is used to setup the database manager class, it should be called after creating a database manager class. |
void |
setHost(java.lang.String host)
Used to set the host name of the database server |
void |
setPassword(java.lang.String password)
Used to set the password used to connect to the database |
void |
setUsername(java.lang.String username)
Used to set the username used to connect to the database |
Methods inherited from class org.stanwood.media.database.AbstractGenericDatabase |
---|
closeConnection, closeDatabaseResources, commitTransactionConnection, createTransactionConnection, dropTable, executeSQL, executeUpdate, executeUpdate, getStatement, insertIntoTable, insertIntoTable, rollbackTransactionConnection |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.stanwood.media.database.IDatabase |
---|
closeConnection, closeDatabaseResources, commitTransactionConnection, createTransactionConnection, dropTable, executeSQL, executeUpdate, executeUpdate, getStatement, insertIntoTable, insertIntoTable, rollbackTransactionConnection |
Constructor Detail |
---|
public MysqlDatabase(java.lang.String host, java.lang.String username, java.lang.String password, java.lang.String database)
host
- The database hostusername
- The name of the user used to access the databasepassword
- The name of the password used to access the databasedatabase
- The name of the database to connect toMethod Detail |
---|
public void init() throws UnableToConnectToDatabaseException
init
in interface IDatabase
UnableToConnectToDatabaseException
public java.lang.String getConnectionUrl()
public java.sql.Connection createConnection() throws java.sql.SQLException
createConnection
in interface IDatabase
java.sql.SQLException
- Thrown if their is a problem getting the connection to the databasepublic void setHost(java.lang.String host)
host
- The host name of the database serverpublic void setUsername(java.lang.String username)
username
- The username used to connect to the databasepublic void setPassword(java.lang.String password)
password
- The password used to connect to the databasepublic boolean dropTable(java.sql.Connection connection, java.lang.String tableName)
dropTable
in interface IDatabase
connection
- The connection to the databasetableName
- The table to delete
public java.sql.PreparedStatement getStatement(java.sql.Connection connection, java.lang.String sql) throws java.sql.SQLException
getStatement
in interface IDatabase
connection
- A connection to the databasesql
- The statements sql
java.sql.SQLException
- Thrown if their is a problem creating the statementPreparedStatement
public void executeSQL(java.sql.Connection connection, java.lang.String sql) throws java.sql.SQLException
executeSQL
in interface IDatabase
connection
- a connection to be re-used, useful for running a series
of updates as a transactionsql
- the SQL to execute on the database
java.sql.SQLException
- Thrown if their is a problem talking to the database
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |