|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.loadbang.sql.Database
public class Database
This is a connection to a database, with some intelligence to support callbacks and understand Max Atoms. Subclasses provide access to actual databases (HSQLDB, MySQL, ...). This class is regarded as abstract, although there's no obvious reason why it cannot be used directly; it doesn't make any abstract calls downstream.
| Nested Class Summary | |
|---|---|
static interface |
Database.ConnectionCallback<T>
An inner interface for connection callbacks. |
| Constructor Summary | |
|---|---|
Database(java.lang.String driver,
java.lang.String url,
java.lang.String user,
java.lang.String password)
Constructor: set up a database connector. |
|
| Method Summary | ||
|---|---|---|
void |
close()
Close the connection. |
|
void |
open()
Open a connection to the database. |
|
java.util.List<com.cycling74.max.Atom[]> |
query(java.lang.String sql)
Simple query method, without any prepared statement support, returning the results as a list of Atom arrays. |
|
int |
update(java.lang.String sql)
Simple update method, without any prepared statement support. |
|
|
withConnection(Database.ConnectionCallback<T> callback)
Execute a callback on the connection; useful for prepared statements. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Database(java.lang.String driver,
java.lang.String url,
java.lang.String user,
java.lang.String password)
throws SetupException
SetupException - if there is some problem finding the JDBC driver| Method Detail |
|---|
public void open()
throws SetupException
SetupException
public int update(java.lang.String sql)
throws OperationException
sql - the SQL string
OperationException - on any SQL error
public java.util.List<com.cycling74.max.Atom[]> query(java.lang.String sql)
throws OperationException
sql - the SQL string
OperationException - on any SQL error
public <T> T withConnection(Database.ConnectionCallback<T> callback)
throws OperationException
T - the type of object to be returned by a query (use Object
for update calls)callback - the callback object
OperationException - if the callback throws this exceptionpublic void close()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||