|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.brains2b.data.cursor.Cursor
Cursor is the Control class for a valid SQL select statement to be be used as a data class for which we can manipulate the data.
This includes inserting, deleting or selecting data, a bit like an Oracle Cursor.
Usage: Create a new Cursor object with a valid SQL connection and a String
containing a valid SQL statement. Cursor c=new Cursor({Valid Connection},"A distinquising name", "SELECT NAME, DEPARTMENT FROM EMP,DEP WHERE NAME.DEP_ID=DEPARTMENT.ID");
After this a Select statement will return a CursorData object. See the javadoc for this object for more information.
To get a new CursorData object use c.getNewCursorData()
Limitation: Updating and inserting will only proceed if the underlying database allows this particular operation for the particular query. Usually this only happens when all reference are explicit, all primary keys are set and all non-null values are filled. Cursor will pass the Exception thrown by the database through when there is a problem with mutating data.
CursorData
Field Summary | |
protected java.sql.Connection |
m_con
|
protected java.lang.String |
m_condition
|
protected java.lang.String |
m_from
|
protected java.lang.String |
m_groupBy
|
protected java.sql.PreparedStatement |
m_prep
|
protected java.lang.String |
m_select
|
Constructor Summary | |
Cursor()
Deprecated. not used, use Cursor(Connection,String,String) |
|
Cursor(java.sql.Connection con,
java.lang.String name,
java.lang.String sql)
Default Constructor for Cursor |
Method Summary | |
int |
delete(CursorData cdata)
Delete the data represented by the CursorData object from the database. |
CursorData |
getNewCursorData()
Get an new CursorData object for this cursor, which has all the fields for this Cursor defined. |
protected CursorData |
getObject(CursorData prototype,
java.sql.ResultSet rs)
get a CursorData object filled from the current position in the ResultSet. |
protected CursorData |
getProtoType(java.sql.ResultSetMetaData rsMd)
get a prototype on the basis of the SQL-statement for this Cursor, which is defined in the ResultSetMetaData. |
java.util.Vector |
select()
Perform a select on the basis of the sql statement defined by this Cursor |
java.util.Vector |
select(Condition con)
Deprecated. use select() |
java.util.Vector |
select(Condition con,
boolean fieldsOnly)
Deprecated. use select() |
java.lang.String |
toString()
Overwritten to return the SQL statement that defines the Cursor |
int |
update(CursorData cdata)
Update the data represented by the CursorData object from the database. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected java.lang.String m_condition
protected java.lang.String m_groupBy
protected java.lang.String m_from
protected java.lang.String m_select
protected java.sql.PreparedStatement m_prep
protected java.sql.Connection m_con
Constructor Detail |
public Cursor()
public Cursor(java.sql.Connection con, java.lang.String name, java.lang.String sql)
con
- java.sql.Connection, a valid non-closed Connectionname
- String, a distinct name for this Cursorsql
- String, a valid ANSI Sql stringMethod Detail |
public int delete(CursorData cdata) throws java.lang.Exception
cdata
- CursorData, an object containing the results for the cursor
Exception,
- thrown if the database delivers an Exception.
java.lang.Exception
public java.util.Vector select(Condition con) throws java.lang.Exception
con
- org.brains2b.sql.Condition, does not do anything.
java.lang.Exception
- thrown if the database delivers an Exceptionpublic java.util.Vector select(Condition con, boolean fieldsOnly) throws java.lang.Exception
con
- org.brains2b.sql.Condition, does not do anything.fieldsOnly
- boolean, ignore the conditions to return all fields
java.lang.Exception
- thrown if the database delivers an Exceptionpublic java.util.Vector select() throws java.lang.Exception
java.lang.Exception
- thrown if the database delivers an Exceptionpublic int update(CursorData cdata) throws java.lang.Exception
cdata
- CursorData, an object containing the results for the cursor
Exception,
- thrown if the database delivers an Exception.
java.lang.Exception
public java.lang.String toString()
toString
in class java.lang.Object
Object.toString()
public CursorData getNewCursorData()
protected CursorData getProtoType(java.sql.ResultSetMetaData rsMd) throws java.sql.SQLException
rsMd
- java.sql.ResultSetMetaData, created on the basis of this cursor SQL-statement
SQLException,
- thrown if the database delivers an SQLException.
java.sql.SQLException
protected CursorData getObject(CursorData prototype, java.sql.ResultSet rs) throws java.sql.SQLException
prototype
- CursorData, object which functions as a prototype, will be
cloned to function as return type.rs
- ResultSet, a resultset with a valid position
SQLException,
- thrown if the resultset has no current position, or
if the database delivers an SQLException
java.sql.SQLException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |