Java Doc for Recordset.java in  » J2EE » Dinamica » dinamica » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » Dinamica » dinamica 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   dinamica.Recordset

Recordset
public class Recordset implements Serializable(Code)
Core-level framework class: Recordset - General purpose, tabular data structure.

Represents a disconnected recordset, a kind of multi-purpose ResultSet without connection to the database, much like the famous ADO disconnected recordset from VB6, can be created from a SQL query or manufactured by code to represent any tabular data. It is a kind of generic data container that may save a lot of work because it can be used to represent several entities avoiding the need to write custom classes to represent each specific entity. It is serializable, so it can be safely used in HTTP Sessions, JNDI, etc.

This recordset mantains all data in memory and does not need an open connection to the database, provides several constructors to isolate the programmer from the task of programming with the JDBC API, but also provides low level access if desired.

Each field in the recordset is mantained in its native data type as represented by the JDBC driver, or a java null value.

Creation date: 10/09/2003
Last Update: 11/09/2003
(c) 2003 Martin Cordova
This code is released under the LGPL license

author:
   Martin Cordova (dinamica@martincordova.com)

Inner Class :class Comp implements Serializable,Comparator<Record>


Constructor Summary
public  Recordset(ResultSet rs)
     Create a recordset given a resultset.
public  Recordset(Connection conn, String sql)
    
public  Recordset(java.sql.Connection conn, String sql, int limit)
     Creates a recordset given a SQL query.
public  Recordset()
    

Method Summary
public  voidaddNew()
    
public  voidappend(String fieldName, int type)
    
public  voidclear()
    
public  booleancontainsField(String name)
    
public  RecordsetcopyStructure()
    
public  voidcopyValues(Recordset rs)
     Copy record values from this recordset to a destination recordset, using the current record of both recordsets.
public  voiddelete(int recNum)
    
public  intfindRecord(String colName, int value)
    
public  intfindRecord(String colName, String value)
    
public  intfindRecord(String colName, java.util.Date value)
    
public  voidfirst()
    
public  RecordsetgetChildrenRecordset()
    
public  ArrayList<Record>getData()
    
public  java.util.DategetDate(String colName)
    
public  doublegetDouble(String colName)
    
public  RecordsetFieldgetField(String fieldName)
    
public  intgetFieldCount()
    
public  HashMap<String, RecordsetField>getFields()
    
public  intgetInt(String colName)
    
public  IntegergetInteger(String colName)
    
public  RecordsetgetMetaData()
     Retrieve recordset metadata.
public  RecordsetgetPage(int p)
    
public  intgetPageCount()
    
public  intgetPageNumber()
    
public  intgetPageSize()
    
public  intgetRecordCount()
    
public  intgetRecordNumber()
    
public  RecordsetgetRecordsetInfo()
    
public  StringgetString(String colName)
    
public  ObjectgetValue(String fieldName)
     Return field value given a field name
Parameters:
  fieldName - Field Name.
public  booleanisNull(String colName)
    
public  voidlast()
    
public  booleannext()
     Move pointer to next record.
public  voidsetChildrenRecordset(Recordset rs)
    
protected  voidsetData(ArrayList data)
    
protected  voidsetFields(HashMap fields)
    
public  voidsetID(String id)
    
public  voidsetPageSize(int p)
    
public  voidsetRecordNumber(int recNum)
    
public  voidsetValue(String fieldName, Object value)
    
public  voidsort(String col)
    
public  StringtoString()
    
public  voidtop()
    


Constructor Detail
Recordset
public Recordset(ResultSet rs) throws Throwable(Code)
Create a recordset given a resultset. It is the responsability of the caller of this method to close the resultset and other jdbc objects involved.
Parameters:
  rs - ResultSet positiones before the first record
throws:
  Throwable -



Recordset
public Recordset(Connection conn, String sql) throws Throwable(Code)
Creates a recordset given a SQL query
Parameters:
  conn - Database Connection
Parameters:
  sql - SQL Query that returns a Resultset
throws:
  Throwable -



Recordset
public Recordset(java.sql.Connection conn, String sql, int limit) throws Throwable(Code)
Creates a recordset given a SQL query.
Parameters:
  conn - Database Connection
Parameters:
  sql - SQL Query that returns a Resultset
Parameters:
  limit - Maximum number of rows to read from the DataBase
throws:
  Throwable -



Recordset
public Recordset()(Code)
Default constructor used when creating the recordset from code (a "manufactured" recordset)




Method Detail
addNew
public void addNew()(Code)
Add a record to the recordset and set record number position to the new inserted record



append
public void append(String fieldName, int type) throws RecordsetException(Code)
Append a field to the recordset structure.
It is used when manufacturing a Recordset from code
Parameters:
  fieldName - Field Name
Parameters:
  nativeSqlType - SQL native data type name
Parameters:
  type - JDBC data type (java.sql.Types) - only INTEGER, LONG, VARCHAR, DATE, TIMESTAMP or DOUBLE are supported



clear
public void clear() throws Throwable(Code)
Clear current record values, set every field's value to null



containsField
public boolean containsField(String name)(Code)
Check if recordset contains field with a given name
Parameters:
  name - Name of the field to check its existence TRUE if field exists, FALSE if not



copyStructure
public Recordset copyStructure() throws Throwable(Code)
Duplicate the Recordset structure in a new Recordset without any data Empty Recordset with the same structure
throws:
  Throwable -



copyValues
public void copyValues(Recordset rs) throws Throwable(Code)
Copy record values from this recordset to a destination recordset, using the current record of both recordsets. Destination recordset fields that match names with source recordset fields must be of the same type too. It does not matter if some fields from the source recordset are not defined in the destination recordset. Only name-matching fields will be considered for the operation.
Parameters:
  rs - Destination recordsets
throws:
  Throwable -



delete
public void delete(int recNum) throws Throwable(Code)
Delete record (from memory)
Parameters:
  recNum - Record Number (0..N-1)



findRecord
public int findRecord(String colName, int value) throws Throwable(Code)
Find a record where a column's value matches a given value
Parameters:
  colName - Column to use for the search
Parameters:
  value - Value to search for Record position (0...N-1) or -1 if not found
throws:
  Throwable -



findRecord
public int findRecord(String colName, String value) throws Throwable(Code)
Find a record where a column's value matches a given value
Parameters:
  colName - Column to use for the search
Parameters:
  value - Value to search for Record position (0...N-1) or -1 if not found
throws:
  Throwable -



findRecord
public int findRecord(String colName, java.util.Date value) throws Throwable(Code)
Find a record where a column's value matches a given Date value
Parameters:
  colName - Column to use for the search
Parameters:
  value - Date value to search for Record position (0...N-1) or -1 if not found
throws:
  Throwable -



first
public void first() throws Throwable(Code)
Set cursor position on first record
throws:
  Throwable -



getChildrenRecordset
public Recordset getChildrenRecordset() throws Throwable(Code)
Retrieve current record's children recordset A reference to the children recordset or null if no children recordset exists
throws:
  Throwable - If the record position is not valid



getData
public ArrayList<Record> getData()(Code)
Returns ArrayList containing the recordset data (the records)



getDate
public java.util.Date getDate(String colName) throws Throwable(Code)
Wrapper method for getValue() - avoids casting the data type
Parameters:
  colName - Column name to retrieve its value from the current record The column value in its native data type
throws:
  Throwable -



getDouble
public double getDouble(String colName) throws Throwable(Code)
Wrapper method for getValue() - avoids casting the data type
Parameters:
  colName - Column name to retrieve its value from the current record The column value in its native data type
throws:
  Throwable -



getField
public RecordsetField getField(String fieldName) throws Throwable(Code)
Return a Recordset field object describing its properties
Parameters:
  fieldName - Field name to locate the field object Reference to Recordset field
throws:
  Throwable - if fieldName does not exist in Recordset metadata



getFieldCount
public int getFieldCount()(Code)
Returns number of fields in recordset



getFields
public HashMap<String, RecordsetField> getFields()(Code)
Returns HashMap containing RecordsetField objects representing the Recordset fields



getInt
public int getInt(String colName) throws Throwable(Code)
Wrapper method for getValue() - avoids casting the data type
Parameters:
  colName - Column name to retrieve its value from the current record The column value in its native data type
throws:
  Throwable -



getInteger
public Integer getInteger(String colName) throws Throwable(Code)
Wrapper method for getValue() - avoids casting the data type
Parameters:
  colName - Column name to retrieve its value from the current record The column value in its native data type
throws:
  Throwable -



getMetaData
public Recordset getMetaData() throws Throwable(Code)
Retrieve recordset metadata. This method returns a Recordset containing the columns: name, typename, typeid. "typeid" is the java.sql.Type value
There will be one record for each column. Recordset
throws:
  Throwable -



getPage
public Recordset getPage(int p) throws Throwable(Code)
Paging support.
Get Recordset representing the requeste page of records



getPageCount
public int getPageCount()(Code)
Paging support.
Returns the number of record pages determined by setPageSize



getPageNumber
public int getPageNumber()(Code)
Paging support.
Returns the current page number (1...N)



getPageSize
public int getPageSize()(Code)
Return records per page (page size) for recordsets used in paged views



getRecordCount
public int getRecordCount()(Code)
Returns the number of records in recordset



getRecordNumber
public int getRecordNumber()(Code)
Returns the current record position (0...N-1)



getRecordsetInfo
public Recordset getRecordsetInfo() throws Throwable(Code)
Create a recordset with one record containing general recordset parameters like: recordcount, pagecount, currentpage Recordset Object
throws:
  Throwable -



getString
public String getString(String colName) throws Throwable(Code)
Wrapper method for getValue() - avoids casting the data type
Parameters:
  colName - Column name to retrieve its value from the current record The column value in its native data type
throws:
  Throwable -



getValue
public Object getValue(String fieldName) throws Throwable(Code)
Return field value given a field name
Parameters:
  fieldName - Field Name. May be reserved field names: _rowIndex (0...N-1) or _rowNumber (1...N)
throws:
  Throwable -



isNull
public boolean isNull(String colName) throws Throwable(Code)
Tests if the give column value is null for the current record
Parameters:
  colName - Column name TRUE if the value is null
throws:
  Throwable - If record position is not valid or the column does not exist in the recordset



last
public void last() throws Throwable(Code)
Set cursor position on last record
throws:
  Throwable -



next
public boolean next()(Code)
Move pointer to next record. Returns true if not EOF



setChildrenRecordset
public void setChildrenRecordset(Recordset rs) throws Throwable(Code)
Set the children recordset for the current record
Parameters:
  rs - Children recordset
throws:
  Throwable - If the record position is not valid



setData
protected void setData(ArrayList data)(Code)
Feed the recordset data
Parameters:
  data - ArrayList containing record objects



setFields
protected void setFields(HashMap fields)(Code)
Feed the recordset metadata (column structure)
Parameters:
  fields - HashMap containing the recordset field objects



setID
public void setID(String id)(Code)
Set recordset ID (an arbitrary String)
Parameters:
  id -



setPageSize
public void setPageSize(int p) throws Throwable(Code)
Paging support.
Define page size (records per page)



setRecordNumber
public void setRecordNumber(int recNum) throws RecordsetException(Code)
Set record position inside recordset
Parameters:
  recNum - Record Number (0...getRecordCount()-1)
throws:
  Throwable -



setValue
public void setValue(String fieldName, Object value) throws RecordsetException(Code)
Set field value for current record (determined by getRecordNumber())
Parameters:
  fieldName - Field Name
Parameters:
  value - Field Value (Date, String, int, double, null)
throws:
  Throwable -



sort
public void sort(String col) throws Throwable(Code)
Sort Recordset data in ascending order by the given column
Parameters:
  col - Name of the column to be used for the sort
throws:
  Throwable -



toString
public String toString()(Code)
Returns a text-formatted report with the structure of the recordset, very usefull for debugging purposes



top
public void top()(Code)
Set cursor position before first record, it is like a "rewind" command



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.