|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectedu.udo.cs.yale.tools.jdbc.DatabaseHandler
public class DatabaseHandler
This class hides the database. Using
connect(String,String,boolean), you can extablish a
connection to the database. Once connected, queries and updates are possible.
| Field Summary | |
|---|---|
private java.lang.String |
databaseURL
|
private java.sql.Connection |
myCon
|
| Constructor Summary | |
|---|---|
DatabaseHandler(java.lang.String databaseURL)
Constructor of the database handler. |
|
| Method Summary | |
|---|---|
void |
addColumn(Attribute attribute,
java.lang.String tableName)
Adds a column for the given attribute to the table with name tableName. |
void |
commit()
Makes all changes to the database permanent. |
void |
connect(java.lang.String username,
java.lang.String passwd,
boolean autoCommit)
Establishes a connection to the database. |
int |
countRecords(java.sql.ResultSet rs)
Counts the number of records in the given result set. |
static java.util.List<Attribute> |
createAttributes(java.sql.ResultSet rs)
Creates a list of attributes reflecting the result set's column meta data. |
void |
disconnect()
Closes the connection to the database. |
private java.util.List<java.lang.String> |
getAllColumnNames(java.lang.String tableName)
|
java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
getAllTableMetaData()
|
static java.lang.String |
getDatabaseName(Attribute attribute)
|
static int |
getYaleTypeIndex(int sqlType)
Returns for the given SQL-type the name of the corresponding Yale-Type from edu.udo.cs.yale.tools.Ontology. |
java.sql.ResultSet |
query(java.lang.String sqlQuery)
Executes the given SQL-Query. |
void |
removeColumn(Attribute attribute,
java.lang.String tableName)
Removes the column of the given attribute from the table with name tableName. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private java.lang.String databaseURL
private java.sql.Connection myCon
| Constructor Detail |
|---|
public DatabaseHandler(java.lang.String databaseURL)
| Method Detail |
|---|
public void connect(java.lang.String username,
java.lang.String passwd,
boolean autoCommit)
throws java.sql.SQLException
username - Name with which to log in to the database.passwd - Password with which to log in to the database.autoCommit - If TRUE, all changes to the database will be committed
automatically. If FALSE, the commit()-Method has to be called
to make changes permanent.
java.sql.SQLException
public void disconnect()
throws java.sql.SQLException
java.sql.SQLException
public java.sql.ResultSet query(java.lang.String sqlQuery)
throws java.sql.SQLException
sqlQuery - An SQL-String.
java.sql.SQLException
public void addColumn(Attribute attribute,
java.lang.String tableName)
throws java.sql.SQLException
java.sql.SQLException
public void removeColumn(Attribute attribute,
java.lang.String tableName)
throws java.sql.SQLException
java.sql.SQLException
public int countRecords(java.sql.ResultSet rs)
throws java.sql.SQLException
rs - The ResultSet.
java.sql.SQLException
public void commit()
throws java.sql.SQLException
java.sql.SQLExceptionpublic static int getYaleTypeIndex(int sqlType)
public static java.util.List<Attribute> createAttributes(java.sql.ResultSet rs)
throws java.sql.SQLException
java.sql.SQLExceptionpublic static java.lang.String getDatabaseName(Attribute attribute)
public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getAllTableMetaData()
throws java.sql.SQLException
java.sql.SQLException
private java.util.List<java.lang.String> getAllColumnNames(java.lang.String tableName)
throws java.sql.SQLException
java.sql.SQLException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||