|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.aitools.programd.util.sql.DbAccess
public class DbAccess
Represents all connection details to a DBMS and allows for getting the input/output streams.
Uses JDBC so as to support any DBMS with a JDBS driver. For use with another DBMS one should change the classname for the Java Driver and the specific URL.
Sample:
driver class name : "oracle.jdbc.dnlddriver.OracleDriver"
specific URL : "dbc:oracle:dnldthin:@ora.doxa.ro:1526:ORCL".
| Field Summary | |
|---|---|
protected Connection |
connection
The Connection used by this object. |
protected String |
driver
The name of the driver used by this object. |
protected String |
password
The password used by this object. |
protected Statement |
statement
The statement used by this object. |
protected String |
url
The URL string used by this object. |
protected String |
user
The user name used by this object. |
| Constructor Summary | |
|---|---|
DbAccess(Connection connectionToUse)
Constructs a DbAccess object given a
Connection object. |
|
DbAccess(String driverToUse,
String urlToUse,
String userToUse,
String passwordToUse)
Constructs a DbAccess object given a driver, url, user
name and password. |
|
| Method Summary | |
|---|---|
void |
connect()
Connects to the database using the values of the fields already set in this object. |
ResultSet |
executeQuery(String query)
Returns the ResultSet from executing a given
query. |
int |
executeUpdate(String update)
Returns the ResultSet from executing a given
update. |
Connection |
getConnection()
Returns the Connection object used by this object. |
String |
getDriver()
Returns the name of the driver used by this object. |
String |
getPassword()
Returns the password used by this object. |
Statement |
getStatement()
Returns the Statement object used by this object. |
String |
getUrl()
Returns the URL string used by this object. |
String |
getUser()
Returns the user name used by this object. |
void |
setConnection(Connection connectionToSet)
Sets the Connection object used by this object. |
void |
setDriver(String driverToSet)
Sets the name of the driver to be used by this object. |
void |
setPassword(String passwordToSet)
Sets the password to be used by this object. |
void |
setUrl(String urlToSet)
Sets the URL string to be used by this object. |
void |
setUser(String userToSet)
Sets the user name to be used by this object. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Connection connection
protected Statement statement
protected String driver
protected String url
protected String user
protected String password
| Constructor Detail |
|---|
public DbAccess(String driverToUse,
String urlToUse,
String userToUse,
String passwordToUse)
DbAccess object given a driver, url, user
name and password.
driverToUse - name of the class representing the Driver to be used
by the Driver managerurlToUse - location of a data source name (dsn)userToUse - user namepasswordToUse - password for userpublic DbAccess(Connection connectionToUse)
DbAccess object given a
Connection object.
connectionToUse - the Connection object from which
to construct the DbAccess object| Method Detail |
|---|
public void connect()
public ResultSet executeQuery(String query)
ResultSet from executing a given
query.
query - the query to execute
ResultSet from executing a given
querypublic int executeUpdate(String update)
ResultSet from executing a given
update.
update - the update to execute
public Connection getConnection()
Connection object used by this object.
public String getDriver()
public String getPassword()
public Statement getStatement()
Statement object used by this object.
public String getUrl()
public String getUser()
public void setConnection(Connection connectionToSet)
Connection object used by this object.
connectionToSet - the Connection object to be usedpublic void setDriver(String driverToSet)
driverToSet - the name of the driver to be usedpublic void setPassword(String passwordToSet)
passwordToSet - the password to be usedpublic void setUrl(String urlToSet)
urlToSet - the URL string to be usedpublic void setUser(String userToSet)
userToSet - the user name to be used
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||