public abstract class AbstractSql extends PropertyResources implements ExitCleaning, Initializable
SqlAccess connection
manager. Provides fields for individual user names and password, as well as
the table name.
As a general hint: java.sql.Date rounds to integer days, retrieve those
fields as a java.sql.Timestamp. If you want to select JD or MJD from a
timestamp field in a PSQL database, use
select extract(epoch from date)/86400+40587 as mjd [,...]
| Modifier and Type | Class and Description |
|---|---|
static class |
AbstractSql.Columns
A class to retrive columns from a database and output it into an
ascii-file for e.g.
|
static class |
AbstractSql.Extract
A class to retrive calumns from a database and output it into an
ascii-file for e.g.
|
PropertyResources.Load, PropertyResources.URLResource| Modifier and Type | Field and Description |
|---|---|
static String |
KEY_TABLE
The key to the table name where star data is stored.
|
private SqlAccess |
sql |
static String |
SQLBATCHDIR
The system key to the directory where the batch queries are stored.
|
static String |
SQLFAILDIR
The system key to the directory where the failed queries are stored.
|
KEY_NOINITONCREATE, POSTFIX_ALPHABET, POSTFIX_BYTES, POSTFIX_DIR, POSTFIX_EXT, POSTFIX_FILE, POSTFIX_LIST, POSTFIX_MODTIME, POSTFIX_URLKEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATORKEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOMECONFIG, KEY_CLASS| Modifier | Constructor and Description |
|---|---|
protected |
AbstractSql(Map<String,String> prop)
Constructs a new abstract sql database.
|
| Modifier and Type | Method and Description |
|---|---|
int |
delete(String where) |
ResultSet |
distinct(Collection<String> fields,
String where) |
ResultSet |
distinct(String where) |
void |
exit()
On exit, we close the connection to the database using our username and
connect string.
|
private static AbstractSql |
generic(Map<String,String> prop)
Creats a database from the properties, will not work if no table is
specified
|
protected SqlAccess |
getAccess() |
private File |
getBatchFile(String dir,
String ext) |
protected static Map<String,String> |
getDefaultArchive() |
DateFormat |
getDefaultFormat() |
String |
getTable()
Returns the table name.
|
void |
init()
If we are not the default user of the database, try to add ourself here.
|
boolean |
insert(Map<String,Object> data) |
boolean |
isEntry(String where)
Returns true, if this where clause returns a non-empty result set.
|
boolean |
release(PreparedStatement rs) |
boolean |
release(ResultSet rs) |
boolean |
replace(Map<String,Object> data,
String where) |
ResultSet |
retrieve(Collection<String> fields,
String where) |
ResultSet |
retrieve(Collection<String> fields,
String where,
String order) |
ResultSet |
retrieve(String where) |
Map<String,Object> |
single(Collection<String> fields,
String where) |
Map<String,Object> |
single(String where) |
clone, createFrom, createFrom, createFrom, createInstance, getApplet, getAsResources, getLocate, getPropertiesToKey, getPropertiesToKey, getResource, getResourceAsStream, getResourceFromKey, getResources, hasLocalURLs, initProperties, keyCreate, keyCreate, reload, setAppletaugment, augment, augment, augment, augment, defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsEnums, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, isNew, parseObject, parseObject, reload, removeProperty, requires, rescanned, setObject, setProperties, setProperty, stringProperties, toStringequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitdefaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, parseObject, removeProperty, setObject, setProperty, stringPropertiespublic static final String KEY_TABLE
public static final String SQLFAILDIR
public static final String SQLBATCHDIR
private SqlAccess sql
public void init()
throws InitException
init in interface InitializableInitExceptionpublic void exit()
exit in interface ExitCleaningpublic String getTable()
public boolean isEntry(String where) throws SQLException
SQLExceptionpublic ResultSet retrieve(String where) throws SQLException
SQLExceptionpublic ResultSet retrieve(Collection<String> fields, String where) throws SQLException
SQLExceptionpublic ResultSet retrieve(Collection<String> fields, String where, String order) throws SQLException
SQLExceptionpublic ResultSet distinct(String where) throws SQLException
SQLExceptionpublic ResultSet distinct(Collection<String> fields, String where) throws SQLException
SQLExceptionpublic Map<String,Object> single(String where) throws SQLException
SQLExceptionpublic Map<String,Object> single(Collection<String> fields, String where) throws SQLException
SQLExceptionpublic boolean insert(Map<String,Object> data) throws SQLException
SQLExceptionpublic boolean replace(Map<String,Object> data, String where) throws SQLException
SQLExceptionpublic int delete(String where) throws SQLException
SQLExceptionpublic boolean release(ResultSet rs)
public boolean release(PreparedStatement rs)
public DateFormat getDefaultFormat()
protected SqlAccess getAccess()
private static AbstractSql generic(Map<String,String> prop) throws InitException
InitException