|
Letzte
Bearbeitung dieses Dokuments: |
Code
Erklärungen
und Anwendungsbeispiele
Verwandte
Dokumentation
package
js_base.dba;
import
java.sql.*;
/**
*
* @author kurt(at)javascout[dot]biz
* @date
2006-06-22
*
* @description
* Base-Class
for Data-Base-Access (DBA) Objects.
* This class
can be inherited by DBA Objects designed for a dedicated
database-table.
*
* The variables in
this class coincide with the variables
* for the
Business Objects base class (JSBS-BO).
* Please
refer to this class for a detailled description of the variables
*
* @change-log
*
when who why
*
--------------------------------------------------------
*
*/public
class JSBS_DBA
{/*
*
CONSTANTS with attribute-names (of the database-table" and
* attribute-strings for SELECT/INSERT and
UPDATE.
* --------------------
* For a
detailled description of each attribute please refer to the VARIABLES
*/
/* ObjectID */ public
final static
String
CONST_ObjectID
=
"ObjectID";/*
ClientID */ public
final static
String
CONST_ClientID
=
"ClientID";/*
DataSetID */ public
final static
String
CONST_DataSetID
=
"DataSetID";/* The
name of the user (if available within the application) who
inserted
* the first database-record with the
'user-key'. */ public
final static
String
CONST_CreatedBy
=
"CreatedBy";/* System-time
when the first database-record with the 'user-key' was inserted.
*/ public
final static
String
CONST_CreatedAt
=
"CreatedAt";/* The
name of the user (if available within the application) who made
* a
change of an attribute of the database-record. */ public
final static
String
CONST_ChangedBy
=
"ChangedBy";/* System-time
when the last change to the database-record was made. */ public
final static
String
CONST_ChangedAt
=
"ChangedAt";/* Date,
from that on (at 0.00 h /midnight) the data in the database-record is
valid. */ public
final static
String
CONST_ValidFrom
=
"ValidFrom";/* Date,
until that (at 24.00 h /midnight) the data in the database-record is
valid. */ public
final static
String
CONST_ValidTill
=
"ValidTill";/*
* String
with all common attributes;
* can be used when
accessing database-tables for SELECT or INSERT. */ public
final static
String
CONST_COMMON_ATTRIBUTES_LIST
=
CONST_ObjectID
+
",
" +
CONST_ClientID
+
",
" +
CONST_DataSetID
+
",
" +
CONST_CreatedBy
+
",
" +
CONST_CreatedAt
+
",
" +
CONST_ChangedBy
+
",
" +
CONST_ChangedAt
+
",
" +
CONST_ValidFrom
+
",
" +
CONST_ValidTill;/*
* String
with all common attributes to be used for UPDATE database-records.
*/ public
final static
String
CONST_COMMON_ATTRIBUTES_LIST_FOR_UPDATE
=
CONST_ObjectID
+
"
= ?, " +
CONST_ClientID
+
"
= ?, " +
CONST_DataSetID
+
"
= ?, " +
CONST_CreatedBy
+
"
= ?, " +
CONST_CreatedAt
+
"
= ?, " +
CONST_ChangedBy
+
"
= ?, " +
CONST_ChangedAt
+
"
= ?, " +
CONST_ValidFrom
+
"
= ?, " +
CONST_ValidTill
+
"
= ?, ";/*
*
VARIABLES reflecting the attributes of the
table.
* -------------------- */
/* ObjectID
contains the 'Surrogate' that was the primary-key of the
database-record
* at the time when a record with a new
'user-key' (individually define for each tatabase-table)
* was
initially inserted. */ public
double
ObjectID;/*
*
ClientID contains the 'Surrogate' that is the primary-key of the
database-record
* which is actually valid.
*/ public
int ClientID;/*
*
DataSetID contains the 'Surrogate' that is the primary-key of the
database-record
* which is actually valid.
*/ public
double
DataSetID;/*
*
The name of the user (if available within the application) who
inserted the
* first database-record with this 'user-key'.
*/ public
String
CreatedBy;/*
*
TimeStamp – Date/Time (down to 1/1000 second) when the first
database-record
* with this 'user-key' was inserted
into the database. */ public
Timestamp
CreatedAt;/*
*
The name of the user (if available within the application) who
made
* the last change of an attribute of the
database-record. */ public
String
ChangedBy;/*
*
TimeStamp – Date/Time (down to 1/1000 second) when the
* last
change of an attribute was written to the database. */ public
Timestamp
ChangedAt;/*
*
Date, from that on (at 00:00 h / midnight) the data in this
database-record is valid. */ public
Date
ValidFrom;/*
*
Date, until that (at 24:00 h / midnight) the data in this
database-record is valid. */ public
Date
ValidTill;/*
*
String with the Error-Message (from the database-system) when the
DB-operation fails. */ public
String
ErrorMsg
=
"";/*
* METHODS
*
-------------------- *//*
*
Method to transfer the values from the SQL-ResultSet (a class within
the
* package java.sql that is filled by a SELECT) to
the variables of this class. */
public
void
getSQLResultSetForCommonAttributes(ResultSet
parmSQLResultSet)
throws
SQLException
{
this.ObjectID
=
parmSQLResultSet.getDouble(CONST_ObjectID);
this.ClientID
=
parmSQLResultSet.getInt(CONST_ClientID);
this.DataSetID
=
parmSQLResultSet.getDouble(CONST_DataSetID);
this.CreatedBy
=
parmSQLResultSet.getString(CONST_CreatedBy);
this.CreatedAt
=
parmSQLResultSet.getTimestamp(CONST_CreatedAt);
this.ChangedBy
=
parmSQLResultSet.getString(CONST_ChangedBy);
this.ChangedAt
=
parmSQLResultSet.getTimestamp(CONST_ChangedAt);
this.ValidFrom
=
parmSQLResultSet.getDate(CONST_ValidFrom);
this.ValidTill
=
parmSQLResultSet.getDate(CONST_ValidTill);
}/*
*
Method to transfer the values from the variables of this class to the
PreparedStatement
* (a class within the package
java.sql that contains the SQL-Statement and the new values
* for
the attributes before a INSERT or UPDATE is called). */
public
void
setSQLStatementWithCommonAttributes(PreparedStatement
parmSQLStatement)
throws
SQLException
{
parmSQLStatement.setDouble(1,
ObjectID);
parmSQLStatement.setInt(2, ClientID);
parmSQLStatement.setDouble(3,
DataSetID);
parmSQLStatement.setString(4,
CreatedBy);
parmSQLStatement.setTimestamp(5,
CreatedAt);
parmSQLStatement.setString(6,
ChangedBy);
parmSQLStatement.setTimestamp(7,
ChangedAt);
parmSQLStatement.setDate(8,
ValidFrom);
parmSQLStatement.setDate(9,
ValidTill);
}
}
xxx
|
Dokument |
Inhalt |
|
Dieser
Leitfaden enthält die notwendigen Tätigkeiten für
die Entwicklung eines StartFrame (auch als Command-Center
bekannt). |