org.deegree_impl.io
Class DBAccess

java.lang.Object
  extended byorg.deegree_impl.io.DBAccess
Direct Known Subclasses:
MySQLDBAccess, OracleSpatialAccess, PostgisDBAccess

public class DBAccess
extends java.lang.Object


Field Summary
protected  java.sql.Connection con
           
private  DBConnectionPool pool
           
 
Constructor Summary
DBAccess(java.sql.Connection con)
          constructor
DBAccess(java.sql.Connection con, boolean autoCommit)
          constructor
DBAccess(java.lang.String driver, java.lang.String logon, java.util.Properties properties)
           
DBAccess(java.lang.String driver, java.lang.String logon, java.util.Properties properties, boolean autoCommit)
           
DBAccess(java.lang.String driver, java.lang.String logon, java.lang.String user, java.lang.String password)
           
DBAccess(java.lang.String driver, java.lang.String logon, java.lang.String user, java.lang.String password, boolean autoCommit)
           
 
Method Summary
 void commit()
          commits the perfomerd queries, inserts and updates if autoCommit is set to false.
protected  java.lang.String escape(java.lang.String query)
          escapes characters depending on the database vendor
 void executeStatement(java.lang.String sql)
          Performs the given SQL-statement against the database.
 java.util.HashMap getColumnTypes(java.lang.String table, java.lang.String[] columns)
          returns a HashMap that maps a column to a data type. if null is submitted for columns all columns are considered.
 java.util.HashMap getColumnTypesAsInt(java.lang.String table, java.lang.String[] columns)
          returns a HashMap that maps a column to a data type. if null is submitted for columns all columns are considered.
 java.sql.Connection getConnection()
          returns the SQL connection encapsulated by the object
 java.lang.String getDataBaseVendor()
          returns the database vendor the access id made to
 void kill()
           
protected  java.lang.String mapTypes(int type)
           
 void performInsert(java.lang.String insert)
          performs the insertion described by the submitted SQL-Statement
 void performInsert(java.lang.String[] insert)
          performs the insertion described by the submitted SQL-Statement
 java.lang.Object performQuery(java.lang.String query)
          perfomrs a general query against a database.
 java.lang.Object performQuery(java.lang.String query, int startFeature, int maxFeatures)
          perfomrs a general query against a database.
 Table performTableQuery(java.lang.String query)
          perfomrs a simple query to get a Table
 Table performTableQuery(java.lang.String query, int startFeature, int maxFeatures)
          perfomrs a simple query to get a Table
 void performUpdate(java.lang.String update)
          performs the update described by the submitted SQL-Statement
 void rollback()
           
 void setAutoCommit(boolean autoCommit)
          sets the auto commit status of the connection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

con

protected java.sql.Connection con

pool

private DBConnectionPool pool
Constructor Detail

DBAccess

public DBAccess(java.sql.Connection con)
constructor

Parameters:
con - connection to a oracle database with spatial extension.

DBAccess

public DBAccess(java.sql.Connection con,
                boolean autoCommit)
         throws java.sql.SQLException
constructor

Parameters:
con - connection to a oracle database with spatial extension.

DBAccess

public DBAccess(java.lang.String driver,
                java.lang.String logon,
                java.lang.String user,
                java.lang.String password)
         throws java.sql.SQLException,
                java.lang.Exception
Parameters:
driver - jdbc driver name
logon - logon (database address, additional parameters)
user -
password -
Throws:
java.sql.SQLException
java.lang.Exception

DBAccess

public DBAccess(java.lang.String driver,
                java.lang.String logon,
                java.util.Properties properties)
         throws java.sql.SQLException,
                java.lang.Exception
Parameters:
driver - jdbc driver name
logon - logon (database address, additional parameters)
properties - additional parameters
Throws:
java.sql.SQLException
java.lang.Exception

DBAccess

public DBAccess(java.lang.String driver,
                java.lang.String logon,
                java.lang.String user,
                java.lang.String password,
                boolean autoCommit)
         throws java.sql.SQLException,
                java.lang.Exception
Parameters:
driver - jdbc driver name
logon - logon (database address, additional parameters)
user -
password -
autoCommit -
Throws:
java.sql.SQLException
java.lang.Exception

DBAccess

public DBAccess(java.lang.String driver,
                java.lang.String logon,
                java.util.Properties properties,
                boolean autoCommit)
         throws java.sql.SQLException,
                java.lang.Exception
Parameters:
driver - jdbc driver name
logon - logon (database address, additional parameters)
properties -
autoCommit -
Throws:
java.sql.SQLException
java.lang.Exception
Method Detail

kill

public void kill()

setAutoCommit

public void setAutoCommit(boolean autoCommit)
                   throws java.lang.Exception
sets the auto commit status of the connection

Throws:
java.lang.Exception

rollback

public void rollback()
              throws java.lang.Exception
Throws:
java.lang.Exception

getConnection

public java.sql.Connection getConnection()
returns the SQL connection encapsulated by the object


performQuery

public java.lang.Object performQuery(java.lang.String query)
                              throws java.sql.SQLException,
                                     java.lang.Exception
perfomrs a general query against a database. The calling class (method) has to know the type of the returned object to cast it to a more specialized class.

Parameters:
query - the query parameter contains the query to perform.
Returns:
result of the query. if the query failed null will be returned.
Throws:
java.sql.SQLException - will be thrown if the submitted query can't be parsed to a valid sql-statement.
java.lang.Exception

performQuery

public java.lang.Object performQuery(java.lang.String query,
                                     int startFeature,
                                     int maxFeatures)
                              throws java.sql.SQLException,
                                     java.lang.Exception
perfomrs a general query against a database. The calling class (method) has to know the type of the returned object to cast it to a more specialized class.

Parameters:
query - the query parameter contains the query to perform.
startFeature - index of the feature the query starts
maxFeatures - the maximum amount of features that should be returned by the request. if maxFeatures is <= 0 all features will be returned.
Returns:
result of the query. if the query failed null will be returned.
Throws:
java.sql.SQLException - will be thrown if the submitted query can't be parsed to a valid sql-statement.
java.lang.Exception

mapTypes

protected java.lang.String mapTypes(int type)

commit

public void commit()
            throws java.sql.SQLException
commits the perfomerd queries, inserts and updates if autoCommit is set to false.

Throws:
java.sql.SQLException

performTableQuery

public Table performTableQuery(java.lang.String query)
                        throws java.lang.Exception
perfomrs a simple query to get a Table

Parameters:
query - the query parameter contains the query to perform.
Returns:
the result of the query as table. the names of the table columns are expressed in capital letters.
Throws:
java.lang.Exception

performTableQuery

public Table performTableQuery(java.lang.String query,
                               int startFeature,
                               int maxFeatures)
                        throws java.lang.Exception
perfomrs a simple query to get a Table

Parameters:
query - the query parameter contains the query to perform.
startFeature - index of the feature the query starts
maxFeatures - the maximum amount of features that should be returned by the request. if maxFeatures is <= 0 all features will be returned.
Returns:
the result of the query as table. the names of the table columns are expressed in capital letters.
Throws:
java.lang.Exception

performUpdate

public void performUpdate(java.lang.String update)
                   throws java.lang.Exception
performs the update described by the submitted SQL-Statement

Parameters:
update - sql-statement that should be performed
Throws:
java.lang.Exception

executeStatement

public void executeStatement(java.lang.String sql)
                      throws java.sql.SQLException
Performs the given SQL-statement against the database.

Parameters:
sql - the SQL-statement to perform
Throws:
java.sql.SQLException - if the SQL was erroneus or a general database error occured

performInsert

public void performInsert(java.lang.String insert)
                   throws java.lang.Exception
performs the insertion described by the submitted SQL-Statement

Parameters:
insert - sql-statement that should be performed
Throws:
java.lang.Exception

performInsert

public void performInsert(java.lang.String[] insert)
                   throws java.lang.Exception
performs the insertion described by the submitted SQL-Statement

Parameters:
insert - sql-statement that should be performed
Throws:
java.lang.Exception

getColumnTypes

public java.util.HashMap getColumnTypes(java.lang.String table,
                                        java.lang.String[] columns)
returns a HashMap that maps a column to a data type. if null is submitted for columns all columns are considered.


getColumnTypesAsInt

public java.util.HashMap getColumnTypesAsInt(java.lang.String table,
                                             java.lang.String[] columns)
returns a HashMap that maps a column to a data type. if null is submitted for columns all columns are considered.


getDataBaseVendor

public java.lang.String getDataBaseVendor()
returns the database vendor the access id made to


escape

protected java.lang.String escape(java.lang.String query)
escapes characters depending on the database vendor