|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbrowser.Console
browser.SQLBrowser
public class SQLBrowser
A command-line interpreter that executes SQL commands against a JDBC-compliant database. The default values of the driver, database, user, and password open my Oracle cs174 database running on Sigma. These must be changed to connect to other databases.
Field Summary | |
---|---|
protected java.sql.Connection |
connection
The connection to a database is a JDBC object: |
protected java.lang.String |
dbasePrefix
The specific database to be opened is identified by a URL of the form PROTOCOL:[@HOST:]PORT:NAME |
protected java.lang.String |
driverName
A JDBC driver converts JDBC queries into database- specific commands. |
protected java.lang.String |
password
|
protected java.sql.ResultSet |
result
Executing most SQL statements results in a virtual table or view, which is represented in JDBC by a ResultSet object. |
protected java.sql.Statement |
statement
Statement seems like a mis-named class. |
protected java.lang.String |
username
Some databases require a login to connect. |
Fields inherited from class browser.Console |
---|
prompt, stderr, stdin, stdout |
Constructor Summary | |
---|---|
SQLBrowser()
|
|
SQLBrowser(java.lang.String dbase)
This constructor attempts to create a new database if the requested database can't be found. |
Method Summary | |
---|---|
java.lang.String |
execute(java.lang.String sql)
This method is called by the control loop in the Console class. |
void |
finalize()
|
protected void |
help()
This method is also called by the Console's control loop |
static void |
main(java.lang.String[] args)
Start the browser |
private java.lang.String |
toString(java.sql.ResultSet rs)
Converts a result set into a formatted string semi-suitable for printing. |
Methods inherited from class browser.Console |
---|
about, controlLoop, handle |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.lang.String driverName
protected java.lang.String dbasePrefix
protected java.lang.String username
protected java.lang.String password
protected java.sql.Connection connection
protected java.sql.Statement statement
protected java.sql.ResultSet result
Constructor Detail |
---|
public SQLBrowser(java.lang.String dbase) throws java.sql.SQLException, java.lang.ClassNotFoundException
java.sql.SQLException
java.lang.ClassNotFoundException
public SQLBrowser() throws java.sql.SQLException, java.lang.ClassNotFoundException
java.sql.SQLException
java.lang.ClassNotFoundException
Method Detail |
---|
public void finalize() throws java.sql.SQLException
finalize
in class java.lang.Object
java.sql.SQLException
private java.lang.String toString(java.sql.ResultSet rs) throws java.sql.SQLException
java.sql.SQLException
public java.lang.String execute(java.lang.String sql) throws AppError
execute
in class Console
AppError
protected void help()
help
in class Console
public static void main(java.lang.String[] args)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |