|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jafer.interfaces.Databean
org.jafer.databeans.JDBC
public abstract class JDBC
Superclass with behaviour common to subclasses. Specific subclasses
configured to make use of specific JDBC drivers should be instantiated.
No caching available, apart from the ResultSet object (which may have a
Forward Only cursor).
XML configuration files:
config.xml
Database
name, username, password for JDBC driver to use.
Toggle to return
results with initial search (piggyback) on/off.
List of XML templates
for creating records of different formats, with locations of the files.
Mappings of Z39.50 Use attributes to SQL database tables and columns. (Also
prefix/append values to add wildcards to SQL query for each.)
Mappings
for translation of Relation attribute values to SQL operators.
OAITemplate.xml
Template record conforming to OAI schema. Data
from database is inserted in place of
MODSTemplate.xml
Template record
conforming to MODS schema. Data from database is inserted in place of
(Column names used in building the SQL query are taken from the XML record template in use, and are expected to be of the form tableName.columnName.)
query.xsl
Field Summary | |
---|---|
private static org.apache.xpath.CachedXPathAPI |
cachedXPath
|
static java.lang.String |
CONFIG_FILE
|
private org.w3c.dom.Document |
configDocument
|
protected java.sql.Connection |
connection
|
private java.lang.String |
currentDatabase
|
protected javax.sql.DataSource |
dataSource
|
protected java.lang.String |
foreignKey
|
private java.lang.String |
hostName
|
static java.util.logging.Logger |
logger
|
protected int |
nResults
|
private java.util.Hashtable |
paramMap
|
protected java.lang.String |
password
|
private int |
port
|
protected java.lang.String |
primaryKey
|
protected java.lang.String |
primaryTable
|
protected org.w3c.dom.Node |
query
|
static java.lang.String |
QUERY_XSLT
|
private java.lang.String |
queryString
|
private java.net.URL |
queryXSLT
|
private int |
recordCursor
|
private org.w3c.dom.Document |
recordDocument
|
private java.lang.String |
recordSchema
|
private java.util.Hashtable |
recordSchemas
|
private org.w3c.dom.Document |
recordTemplate
|
protected java.sql.ResultSet |
resultSet
|
private JaferException |
searchException
Stores a reference to exception that occured in the last search or null if no errors occured |
protected java.lang.String |
username
|
Constructor Summary | |
---|---|
JDBC()
Loads configuration info from config files. |
Method Summary | |
---|---|
protected boolean |
alignCursor()
|
protected abstract void |
configureDataSource()
|
private Field |
createRecord()
|
private java.lang.String |
getAttributeValue(org.w3c.dom.Node node,
java.lang.String attName)
|
protected java.sql.Connection |
getConnection()
Gets a conection from the DataSource in use. |
java.lang.String |
getCurrentDatabase()
Get database of current record |
Field |
getCurrentRecord()
Creates record from data in database, following the layout of the chosen record template. |
java.lang.String[] |
getDatabases()
Returns an array containing the name of the single database that can be searched. |
java.lang.String |
getElementSpec()
Get current element specification setting |
java.lang.String |
getHost()
Get current Z39.50 host |
int |
getNumberOfResults()
Get number of results for last query |
int |
getNumberOfResults(java.lang.String databaseName)
Get number of results from the named database for last query |
int |
getPort()
Get Z39.50 datasource IP Port |
java.lang.Object |
getQuery()
Get the last submitted query |
protected java.lang.String |
getQueryString()
|
int |
getRecordCursor()
Get the current record position cursor |
java.lang.String |
getRecordSchema()
Get currently set record schema |
java.lang.String |
getResultSetName()
|
protected JaferException |
getSearchException()
This method returns the JaferException from the last search. |
JaferException |
getSearchException(java.lang.String database)
If a search fails this method will return the JaferException for the specified database |
JaferException[] |
getSearchException(java.lang.String[] databases)
If a search fails this method will return the JaferException for the specified databases |
java.lang.String |
getSearchProfile()
|
protected java.sql.Statement |
getStatement()
Gets a new Statement, which can be modified in subclasses. |
protected java.lang.String |
getXMLConfigValue(java.lang.String XPath)
|
private void |
initialise()
Loads XML config file, sets available schemas (and default schema). Loads query transform stylesheet. Loads database name, user name and password for JDBC conection from XML config file. |
boolean |
isCheckRecordFormat()
Get record schema checking setting |
boolean |
isParseQuery()
|
private void |
loadRecordSchemas()
|
protected java.util.Vector |
processInsert(java.lang.String columnName)
|
private org.apache.xpath.NodeSet |
processJaferData(org.w3c.dom.Node jaferNode)
|
private org.apache.xpath.NodeSet |
processJaferElement(org.w3c.dom.Node jaferNode,
org.apache.xpath.NodeSet childSet)
|
private org.apache.xpath.NodeSet |
processNode(org.w3c.dom.Node node)
|
private org.w3c.dom.Node |
processTemplate(org.w3c.dom.Node template)
|
void |
saveQuery(java.lang.String filePath)
|
protected void |
search()
Executes search on database using current query. |
private org.w3c.dom.Node |
selectNode(org.w3c.dom.Node sourceNode,
java.lang.String XPath)
|
private org.w3c.dom.NodeList |
selectNodeList(org.w3c.dom.Node sourceNode,
java.lang.String XPath)
|
void |
setCheckRecordFormat(boolean checkRecordFormat)
Throw exception is record schema not preferred schema |
private void |
setDatabaseConfiguration()
|
void |
setDatabases(java.lang.String database)
Method doesn't do anything. |
void |
setDatabases(java.lang.String[] databases)
Method doesn't do anything. |
void |
setElementSpec(java.lang.String elementSpec)
Set element specification for record retrieval |
void |
setHost(java.lang.String hostName)
Z39.50 Host address |
void |
setParseQuery(boolean parseQuery)
|
void |
setPort(int port)
Set Z39.50 datasource IP port |
protected void |
setQueryString(java.lang.String selectPhrase)
Transforms XML query to SQL string via stylesheet. |
void |
setRecordCursor(int nRecord)
Set the current record cursor |
void |
setRecordSchema(java.lang.String schema)
Sets record format to be produced, using name of XML Schema for record format. If a suitable template is not available, uses default record format set in config.xml, or last schema set successfully. |
private void |
setRecordTemplate(java.lang.String schema)
|
void |
setResultSetName(java.lang.String resultSetName)
|
protected void |
setSearchException(JaferException exc)
This method sets the last exception that occurred during a search |
void |
setSearchProfile(java.lang.String searchProfile)
|
int |
submitQuery(org.w3c.dom.Node query)
|
int |
submitQuery(java.lang.Object query)
Send query (can be in XML form) |
int |
submitQuery(z3950.v3.RPNQuery query)
|
Methods inherited from class org.jafer.interfaces.Databean |
---|
getCacheSupport, getPresentSupport, getScanSupport, getSearchSupport |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static java.util.logging.Logger logger
private java.net.URL queryXSLT
private org.w3c.dom.Document configDocument
private org.w3c.dom.Document recordTemplate
private org.w3c.dom.Document recordDocument
private java.util.Hashtable paramMap
private java.util.Hashtable recordSchemas
protected org.w3c.dom.Node query
protected javax.sql.DataSource dataSource
protected java.sql.Connection connection
protected java.sql.ResultSet resultSet
private java.lang.String hostName
private java.lang.String currentDatabase
private java.lang.String recordSchema
private java.lang.String queryString
protected java.lang.String username
protected java.lang.String password
protected java.lang.String primaryTable
protected java.lang.String primaryKey
protected java.lang.String foreignKey
private int port
private int recordCursor
protected int nResults
private static org.apache.xpath.CachedXPathAPI cachedXPath
public static final java.lang.String CONFIG_FILE
public static final java.lang.String QUERY_XSLT
private JaferException searchException
Constructor Detail |
---|
public JDBC()
initialise()
Method Detail |
---|
public void setHost(java.lang.String hostName)
Z3950Connection
setHost
in interface Z3950Connection
hostName
- Host ip addresspublic java.lang.String getHost()
Z3950Connection
getHost
in interface Z3950Connection
public void setPort(int port)
Z3950Connection
setPort
in interface Z3950Connection
public int getPort()
Z3950Connection
getPort
in interface Z3950Connection
public void setRecordCursor(int nRecord) throws JaferException
Present
setRecordCursor
in interface Present
nRecord
- Record position (starting at 1)
JaferException
public int getRecordCursor()
Present
getRecordCursor
in interface Present
public void setCheckRecordFormat(boolean checkRecordFormat)
Present
setCheckRecordFormat
in interface Present
checkRecordFormat
- setting of record schema checkingpublic boolean isCheckRecordFormat()
Present
isCheckRecordFormat
in interface Present
public void setElementSpec(java.lang.String elementSpec)
Present
setElementSpec
in interface Present
elementSpec
- element specificationpublic java.lang.String getElementSpec()
Present
getElementSpec
in interface Present
public void setRecordSchema(java.lang.String schema)
setRecordSchema
in interface Present
schema
- record schemapublic java.lang.String getRecordSchema()
Present
getRecordSchema
in interface Present
public Field getCurrentRecord() throws JaferException
getCurrentRecord
in interface Present
JaferException
public java.lang.String getCurrentDatabase()
Present
getCurrentDatabase
in interface Present
public void setSearchProfile(java.lang.String searchProfile)
public java.lang.String getSearchProfile()
public void setResultSetName(java.lang.String resultSetName)
setResultSetName
in interface Search
public java.lang.String getResultSetName()
getResultSetName
in interface Search
public void setDatabases(java.lang.String database)
config.xml
)
setDatabases
in interface Search
database
- (not used)public void setDatabases(java.lang.String[] databases)
config.xml
)
setDatabases
in interface Search
databases
- (not used)public java.lang.String[] getDatabases()
config.xml
)
getDatabases
in interface Search
public void setParseQuery(boolean parseQuery)
setParseQuery
in interface Search
public boolean isParseQuery()
isParseQuery
in interface Search
public int submitQuery(java.lang.Object query) throws JaferException
Search
submitQuery
in interface Search
JaferException
public int submitQuery(z3950.v3.RPNQuery query) throws JaferException
JaferException
public int submitQuery(org.w3c.dom.Node query) throws JaferException
JaferException
public void saveQuery(java.lang.String filePath) throws JaferException
saveQuery
in interface Search
JaferException
public int getNumberOfResults()
Search
getNumberOfResults
in interface Search
public int getNumberOfResults(java.lang.String databaseName)
Search
getNumberOfResults
in interface Search
public java.lang.Object getQuery()
Search
getQuery
in interface Search
protected void search() throws java.sql.SQLException, JaferException
java.sql.SQLException
JaferException
protected java.sql.Connection getConnection() throws java.sql.SQLException
java.sql.SQLException
protected java.sql.Statement getStatement() throws java.sql.SQLException
java.sql.SQLException
protected void setQueryString(java.lang.String selectPhrase) throws JaferException
JaferException
protected java.lang.String getQueryString()
private Field createRecord() throws java.sql.SQLException, JaferException
java.sql.SQLException
JaferException
private org.w3c.dom.Node processTemplate(org.w3c.dom.Node template) throws java.sql.SQLException, JaferException
java.sql.SQLException
JaferException
private org.apache.xpath.NodeSet processNode(org.w3c.dom.Node node) throws java.sql.SQLException, JaferException
java.sql.SQLException
JaferException
private org.apache.xpath.NodeSet processJaferElement(org.w3c.dom.Node jaferNode, org.apache.xpath.NodeSet childSet) throws JaferException, java.sql.SQLException
JaferException
java.sql.SQLException
private org.apache.xpath.NodeSet processJaferData(org.w3c.dom.Node jaferNode) throws JaferException, java.sql.SQLException
JaferException
java.sql.SQLException
protected java.util.Vector processInsert(java.lang.String columnName) throws java.sql.SQLException, JaferException
java.sql.SQLException
JaferException
protected boolean alignCursor() throws java.sql.SQLException, JaferException
java.sql.SQLException
JaferException
private void initialise() throws JaferException
JaferException
private void setDatabaseConfiguration() throws JaferException
JaferException
protected abstract void configureDataSource() throws JaferException
JaferException
private void loadRecordSchemas() throws JaferException
JaferException
private void setRecordTemplate(java.lang.String schema)
protected java.lang.String getXMLConfigValue(java.lang.String XPath) throws JaferException
JaferException
private org.w3c.dom.Node selectNode(org.w3c.dom.Node sourceNode, java.lang.String XPath) throws JaferException
JaferException
private org.w3c.dom.NodeList selectNodeList(org.w3c.dom.Node sourceNode, java.lang.String XPath) throws JaferException
JaferException
private java.lang.String getAttributeValue(org.w3c.dom.Node node, java.lang.String attName)
public JaferException getSearchException(java.lang.String database) throws JaferException
Search
getSearchException
in interface Search
database
- The name of the database to check
JaferException
public JaferException[] getSearchException(java.lang.String[] databases) throws JaferException
Search
getSearchException
in interface Search
databases
- The databases to search
JaferException
protected JaferException getSearchException()
protected void setSearchException(JaferException exc)
exc
- The exception that occurred
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |