com.onewebsql.query
Interface DBAdapter

All Known Implementing Classes:
BaseDBAdapter, DB2DBAdapter, HSQLDB2Adapter, MSSQLDBAdapter, MySQLDBAdapter, OracleDBAdapter, PostgresDBAdapter

public interface DBAdapter

Database adapter interface, provides information specific for one database type (PostgreSQL, Oracle, IBM DB2, etc.).


Method Summary
 void buildQuery(SelectQuery query, String schemaName, StringBuilder sb, List<Value> objs)
          Builds a SELECT query in a way specific for the database.
 boolean getBlob(DataSource ds, String schemaName, Column column, Object id, OutputStream is, long length)
          Retrieves the value of Blob column and writes its contents to the specified stream.
 boolean getClob(DataSource ds, String schemaName, Column column, Object id, Writer writer, long length)
          Retrieves the value of Clob column and writes its contents to the specified Writer.
 Long getNextId(String sequenceName, String schemaName, DataSource ds)
          Returns the next value from the sequence with the specified name and the specified schema name, from the specified data source.
 ParameterHandler<List<Value>> getValueListParameterHandler()
          Returns an object binding the value lists built by OneWebSQL to SQL query parameters in a way specific for the database.
 boolean join(Join join, String schemaName, StringBuilder sb, List<Value> objs)
          Builds a join query in a way specific for the database.
 void setBlob(DataSource ds, String schemaName, Column column, Object id, InputStream is, long length)
          Reads from the specified stream and writes its contents to the Blob column.
 void setClob(DataSource ds, String schemaName, Column column, Object id, Reader reader, long length)
          Reads from the specified Reader and writes its contents to the Clob column.
 

Method Detail

join

boolean join(Join join,
             String schemaName,
             StringBuilder sb,
             List<Value> objs)
Builds a join query in a way specific for the database. If the join queries are standard in this database the method should do nothing and return false.

Parameters:
join - join query
schemaName - schema name used to build the query
sb - StringBuilder where we build the query
objs - an accumulator list to which join parameters are added
Returns:
false if the method did nothing or true if the method builds the query

buildQuery

void buildQuery(SelectQuery query,
                String schemaName,
                StringBuilder sb,
                List<Value> objs)
Builds a SELECT query in a way specific for the database.

Parameters:
query - SELECT query
schemaName - schema name used to build the query
sb - StringBuilder where we build the query
objs - an accumulator list to which join parameters are added

getNextId

Long getNextId(String sequenceName,
               String schemaName,
               DataSource ds)
Returns the next value from the sequence with the specified name and the specified schema name, from the specified data source.

Parameters:
sequenceName - sequence name
schemaName - name of the schema
ds - data source
Returns:
next value of the sequence

setBlob

void setBlob(DataSource ds,
             String schemaName,
             Column column,
             Object id,
             InputStream is,
             long length)
Reads from the specified stream and writes its contents to the Blob column. The specified row must exist in the database. The row identifier might be

Parameters:
ds - data source
schemaName - name of the table's schema
column - column to which we are writing
id - row id
is - InputStream containing data to write or null if the column is to be set to NULL
length - the number of bytes to write or -1 if the whole stream content is to be written

getBlob

boolean getBlob(DataSource ds,
                String schemaName,
                Column column,
                Object id,
                OutputStream is,
                long length)
Retrieves the value of Blob column and writes its contents to the specified stream. The row must exist in the database. The row identifier might be:

Parameters:
ds - data source
schemaName - name of the table's schema
column - column we are reading
id - row id
is - OutputStream to which the column contents is to be written
length - the maximal number of bytes to write or -1 if the whole column contents is to be written
Returns:
true if the column value was retrieved false if the column value was NULL

setClob

void setClob(DataSource ds,
             String schemaName,
             Column column,
             Object id,
             Reader reader,
             long length)
Reads from the specified Reader and writes its contents to the Clob column. The specified row must exist in the database. The row identifier might be

Parameters:
ds - data source
schemaName - name of the table's schema
column - column to which we are writing
id - row id
reader - Reader containing data to write or null if the column is to be set to NULL
length - the number of bytes to write or -1 if the whole stream content is to be written

getClob

boolean getClob(DataSource ds,
                String schemaName,
                Column column,
                Object id,
                Writer writer,
                long length)
Retrieves the value of Clob column and writes its contents to the specified Writer. The row must exist in the database. The row identifier might be:

Parameters:
ds - data source
schemaName - name of the table's schema
column - column we are reading
id - row id
writer - writer to which the column contents is to be written
length - the maximal number of bytes to write or -1 if the whole column contents is to be written
Returns:
true if the column value was retrieved false if the column value was NULL

getValueListParameterHandler

ParameterHandler<List<Value>> getValueListParameterHandler()
Returns an object binding the value lists built by OneWebSQL to SQL query parameters in a way specific for the database.

Returns:
an object binding value lists to SQL query parameters
See Also:
SelectQuery.build(StringBuilder, String, List, DBAdapter), InsertQuery.build(StringBuilder, String, List, DBAdapter), DeleteQuery.build(StringBuilder, String, List, DBAdapter)


Copyright © 2011-2013 e-point SA. All Rights Reserved.