xmlBlaster 2.2.0 API

org.xmlBlaster.util.queue.jdbc
Class XBFactory

java.lang.Object
  extended by org.xmlBlaster.util.queue.jdbc.XBFactoryBase
      extended by org.xmlBlaster.util.queue.jdbc.XBFactory
Direct Known Subclasses:
XBMeatFactory, XBRefFactory, XBStoreFactory

public abstract class XBFactory
extends XBFactoryBase

Author:
Marcel Ruff, Michele Laghi

Field Summary
protected  java.lang.String base
           
protected  java.lang.String countSt
           
protected  java.lang.String createSt
           
protected  java.lang.String deleteAllSt
           
protected  java.lang.String deleteCompleteSt
           
protected  java.lang.String deleteSt
           
protected  java.lang.String deleteTransientsSt
           
protected  java.lang.String dropSt
           
protected  java.lang.String getAllSt
           
protected  java.lang.String getCompleteSt
           
protected  java.lang.String getFirstEntriesSt
           
protected  java.lang.String getNumOfAllSt
           
protected  java.lang.String getSt
           
protected  java.lang.String inList
           
protected  java.lang.String insertSt
           
private static java.util.logging.Logger log
           
protected  java.lang.String prefix
           
protected  java.lang.String table
           
private  java.lang.String tableNameDefault
           
private static boolean useBinary
           
private static boolean useString
           
private static boolean useString2
           
 
Fields inherited from class org.xmlBlaster.util.queue.jdbc.XBFactoryBase
DB2, FIREBIRD, HSQLDB, LDBC, MYSQL, ORACLE, POSTGRES, SQLITE, SQLSERVER_2000, SQLSERVER_2005, UNKNOWN
 
Constructor Summary
XBFactory(java.lang.String prefix, java.lang.String name)
           xbmeatid NUMBER(20) primary key, xbdurable char default 'F' not null, xbrefcount NUMBER(10), xbbytesize NUMBER(10), xbdatatype varchar(32) default '' not null, xbflag1 varchar(32) default '', xbmsgqos clob default '', xbmsgcont blob default '', xbmsgkey clob default ''
 
Method Summary
protected  boolean checkSameStore(XBStore store, XBEntry entry)
           
 long count(XBStore store, java.sql.Connection conn, int timeout)
          Deletes the specified entries.
 boolean create(java.sql.Connection conn)
          Returns true if the table has been created, false otherwise.
 int delete(long storeId, long id, java.sql.Connection conn, int timeout)
           
 long deleteList(XBStore store, java.sql.Connection conn, XBEntry[] entries, int maxStLength, int maxNumSt, boolean commitInBetween, int timeout)
          Deletes the specified entries.
 int deleteTransients(long storeId, java.sql.Connection conn, int timeout)
           
 boolean drop(java.sql.Connection conn)
          Returns true if it could delete the table, false otherwise.
private  boolean exists(java.sql.Connection conn)
          Checks if the table already exists, the check is done against the meta data.
static void fillDbCol(java.sql.PreparedStatement preStatement, int index, java.lang.String value)
          String/VARCHAR/CLOB helper to avoid NULL and to take care on Umlauts/UTF-8
protected abstract  long getByteSize(java.sql.ResultSet rs, int offset)
           
static java.lang.String getDbCol(java.sql.ResultSet rs, int index)
          String/VARCHAR/CLOB helper to avoid NULL and to take care on Umlauts/UTF-8
 java.util.List<XBEntry> getList(XBStore store, java.sql.Connection conn, XBEntry[] entries, int maxStLength, int maxNumSt, int timeout)
          Gets the specified entries.
 EntryCount getNumOfAll(XBStore store, java.sql.Connection conn)
          Gets the real number of entries.
 I_Info init(I_Info origInfo)
           
protected static boolean isTrue(java.lang.String asTxt)
           
protected  void prepareDefaultStatements()
          This method must be implemented in all underlying extentions to this class.
protected static byte[] readStream(java.io.InputStream inStream)
           
protected abstract  XBEntry rsToEntry(XBStore store, java.sql.ResultSet rs)
           
protected  java.util.List<java.lang.String> whereInStatement(java.lang.String reqPrefix, XBEntry[] entries, int maxStatementLength, int maxNumStatements)
          The prefix is the initial part of the SQL update/query.
 
Methods inherited from class org.xmlBlaster.util.queue.jdbc.XBFactoryBase
doInit, getDbVendor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static final java.util.logging.Logger log

insertSt

protected java.lang.String insertSt

getSt

protected java.lang.String getSt

getAllSt

protected java.lang.String getAllSt

getCompleteSt

protected java.lang.String getCompleteSt

deleteAllSt

protected java.lang.String deleteAllSt

deleteCompleteSt

protected java.lang.String deleteCompleteSt

deleteTransientsSt

protected java.lang.String deleteTransientsSt

getFirstEntriesSt

protected java.lang.String getFirstEntriesSt

getNumOfAllSt

protected java.lang.String getNumOfAllSt

deleteSt

protected java.lang.String deleteSt

createSt

protected java.lang.String createSt

countSt

protected java.lang.String countSt

dropSt

protected java.lang.String dropSt

prefix

protected java.lang.String prefix

table

protected java.lang.String table

tableNameDefault

private java.lang.String tableNameDefault

inList

protected java.lang.String inList

base

protected java.lang.String base

useString

private static final boolean useString
See Also:
Constant Field Values

useString2

private static final boolean useString2
See Also:
Constant Field Values

useBinary

private static final boolean useBinary
See Also:
Constant Field Values
Constructor Detail

XBFactory

public XBFactory(java.lang.String prefix,
                 java.lang.String name)
 xbmeatid NUMBER(20) primary key,
 xbdurable char default 'F' not null,
 xbrefcount NUMBER(10),
 xbbytesize NUMBER(10),
 xbdatatype varchar(32) default '' not null,
 xbflag1 varchar(32) default '',
 xbmsgqos clob default '',
 xbmsgcont blob default '',
 xbmsgkey clob default ''
 

Method Detail

init

public final I_Info init(I_Info origInfo)
                  throws XmlBlasterException
Overrides:
init in class XBFactoryBase
Throws:
XmlBlasterException

delete

public int delete(long storeId,
                  long id,
                  java.sql.Connection conn,
                  int timeout)
           throws java.sql.SQLException
Throws:
java.sql.SQLException

deleteTransients

public int deleteTransients(long storeId,
                            java.sql.Connection conn,
                            int timeout)
                     throws java.sql.SQLException
Throws:
java.sql.SQLException

rsToEntry

protected abstract XBEntry rsToEntry(XBStore store,
                                     java.sql.ResultSet rs)
                              throws java.sql.SQLException,
                                     java.io.IOException
Throws:
java.sql.SQLException
java.io.IOException

exists

private final boolean exists(java.sql.Connection conn)
                      throws java.sql.SQLException
Checks if the table already exists, the check is done against the meta data.

Parameters:
conn -
Returns:
Throws:
java.sql.SQLException

create

public boolean create(java.sql.Connection conn)
               throws java.sql.SQLException
Returns true if the table has been created, false otherwise. It returns false for example if the table existed already, in which case it is not newly created.

Parameters:
conn -
Returns:
Throws:
java.sql.SQLException

drop

public final boolean drop(java.sql.Connection conn)
                   throws java.sql.SQLException
Returns true if it could delete the table, false otherwise. It would return false if the table did not exist.

Parameters:
conn -
Returns:
Throws:
java.sql.SQLException

readStream

protected static final byte[] readStream(java.io.InputStream inStream)
                                  throws java.io.IOException
Throws:
java.io.IOException

getDbCol

public static final java.lang.String getDbCol(java.sql.ResultSet rs,
                                              int index)
                                       throws java.sql.SQLException,
                                              java.io.IOException
String/VARCHAR/CLOB helper to avoid NULL and to take care on Umlauts/UTF-8

Parameters:
preStatement -
index -
value -
Throws:
java.sql.SQLException
java.io.IOException

fillDbCol

public static final void fillDbCol(java.sql.PreparedStatement preStatement,
                                   int index,
                                   java.lang.String value)
                            throws java.sql.SQLException,
                                   java.io.UnsupportedEncodingException
String/VARCHAR/CLOB helper to avoid NULL and to take care on Umlauts/UTF-8

Parameters:
preStatement -
index -
value -
Throws:
java.sql.SQLException
java.io.UnsupportedEncodingException

prepareDefaultStatements

protected void prepareDefaultStatements()
This method must be implemented in all underlying extentions to this class. It returns (for the different database vendors a default for the creation of the table.


whereInStatement

protected final java.util.List<java.lang.String> whereInStatement(java.lang.String reqPrefix,
                                                                  XBEntry[] entries,
                                                                  int maxStatementLength,
                                                                  int maxNumStatements)
The prefix is the initial part of the SQL update/query. Note that this method can be used both for SELECT statements as for updates such as DELETE or UPDATE. An example of prefix: "delete from tableName where dataId in(";


deleteList

public long deleteList(XBStore store,
                       java.sql.Connection conn,
                       XBEntry[] entries,
                       int maxStLength,
                       int maxNumSt,
                       boolean commitInBetween,
                       int timeout)
                throws java.sql.SQLException
Deletes the specified entries. Since all entry may not fit in one single operation, they are splitted over different operations. If you specified commitInBetween or the auto-commit flag is set to true, It always returns the number of deleted entries. If a batch could not be completely deleted, it returns the number of operations previously deleted.

Parameters:
store - the store to use.
the - connection to be used.
ids - the array containing all ids to delete.
Returns:
the number of entries successfully processed. These are the first. If an error occurs it stops.
Throws:
java.sql.SQLException

count

public long count(XBStore store,
                  java.sql.Connection conn,
                  int timeout)
           throws java.sql.SQLException
Deletes the specified entries. Since all entry may not fit in one single operation, they are splitted over different operations. If you specified commitInBetween or the auto-commit flag is set to true, It always returns the number of deleted entries. If a batch could not be completely deleted, it returns the number of operations previously deleted.

Parameters:
store - the store to use.
the - connection to be used.
ids - the array containing all ids to delete.
Returns:
the number of entries successfully processed. These are the first. If an error occurs it stops.
Throws:
java.sql.SQLException

getList

public java.util.List<XBEntry> getList(XBStore store,
                                       java.sql.Connection conn,
                                       XBEntry[] entries,
                                       int maxStLength,
                                       int maxNumSt,
                                       int timeout)
                                throws java.sql.SQLException,
                                       java.io.IOException
Gets the specified entries. Since all entry may not fit in one single operation, they are splitted over different operations. If you specified commitInBetween or the auto-commit flag is set to true, It always returns the number of deleted entries. If a batch could not be completely deleted, it returns the number of operations previously deleted.

Parameters:
store - the store to use.
the - connection to be used.
ids - the array containing all ids to delete.
Returns:
the number of entries successfully processed. These are the first. If an error occurs it stops.
Throws:
java.sql.SQLException
java.io.IOException

getByteSize

protected abstract long getByteSize(java.sql.ResultSet rs,
                                    int offset)
                             throws java.sql.SQLException
Throws:
java.sql.SQLException

getNumOfAll

public final EntryCount getNumOfAll(XBStore store,
                                    java.sql.Connection conn)
                             throws java.sql.SQLException
Gets the real number of entries. That is it really makes a call to the DB to find out how big the size is.

Returns:
never null
Throws:
java.sql.SQLException

isTrue

protected static final boolean isTrue(java.lang.String asTxt)

checkSameStore

protected final boolean checkSameStore(XBStore store,
                                       XBEntry entry)

xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.