|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.caucho.jslib.Database
public class Database
Encapsulates a database connection for JavaScript.
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 Summary | |
---|---|
Database(java.lang.String name)
Creates a new database looking up the DataSource in JNDI. |
Method Summary | |
---|---|
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. |
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 name) throws java.lang.Exception
name
- jndi name to the data source
java.lang.Exception
Method Detail |
---|
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
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |