public class Database
extends java.lang.Object
var conn = new Database("jdbc/test");
var rs = conn.query("select NAME from HOUSES");
while (rs.next())
out.writeln(rs.get(1) + "<br/>");
conn.close();
Constructor and Description |
---|
Database(java.lang.String name)
Creates a new database looking up the DataSource in JNDI.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the connection.
|
void |
commit()
Commits the current connection.
|
java.sql.Connection |
getConnection()
Returns the JDBC Connection for the database.
|
javax.sql.DataSource |
getDataSource()
Returns the JDBC DataSource.
|
java.sql.Statement |
getStatement()
Returns the JDBC Statement for the database.
|
java.sql.PreparedStatement |
prepare(java.lang.String sql)
Returns the JDBC Statement for the database.
|
java.sql.ResultSet |
query(java.lang.String sql)
Execute the sql as a query.
|
int |
update(java.lang.String sql)
Execute the sql as a query.
|
public Database(java.lang.String name) throws java.lang.Exception
name
- jndi name to the data sourcejava.lang.Exception
public java.sql.ResultSet query(java.lang.String sql) throws java.sql.SQLException
java.sql.SQLException
public int update(java.lang.String sql) throws java.sql.SQLException
java.sql.SQLException
public javax.sql.DataSource getDataSource() throws java.sql.SQLException
java.sql.SQLException
public java.sql.Connection getConnection() throws java.sql.SQLException
java.sql.SQLException
public void commit() throws java.sql.SQLException
java.sql.SQLException
public java.sql.Statement getStatement() throws java.sql.SQLException
java.sql.SQLException
public java.sql.PreparedStatement prepare(java.lang.String sql) throws java.sql.SQLException
java.sql.SQLException
public void close() throws java.sql.SQLException
java.sql.SQLException