|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectbe.six.reports.data.Database
public class Database
The Database class represents a database. The connection parameters and driver are configured trough the java preferences API: http://java.sun.com/j2se/1.4.2/docs/guide/lang/preferences.html The specified database driver has to be available in the ClassPath.
| Method Summary | |
|---|---|
void |
close()
closes the database connection |
DatabaseResult |
fetchData(java.lang.String sql)
|
DatabaseResult |
fetchData(java.lang.String sql,
java.util.List<java.lang.Object> parameters)
Sets the parameters in parameters in order and fetches data using a prepared statement. |
static Database |
getInstance()
|
DatabaseResult |
queryWithOneParam(java.lang.String sql,
java.lang.Object param)
Queries the database with only one parameter. |
DatabaseResult |
testResult()
testResult is used to test the database connection |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static Database getInstance()
public DatabaseResult testResult()
throws java.sql.SQLException
java.sql.SQLException - if something goes awry
public DatabaseResult fetchData(java.lang.String sql)
throws java.sql.SQLException
sql - the select query to execute
java.sql.SQLException
public DatabaseResult fetchData(java.lang.String sql,
java.util.List<java.lang.Object> parameters)
throws java.sql.SQLException
sql - the sql with question mark parameters e.g. select * from table where id = ? and name like ?parameters - a list of parameters e.g. [10,"%a name"]
java.sql.SQLException - when something goes awry.public void close()
public DatabaseResult queryWithOneParam(java.lang.String sql,
java.lang.Object param)
sql - the SQL statement with one question mark parameter e.g. select * from table where id = ?param - a parameter e.g. 10
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||