org.openrdf.sesame.sailimpl.rdbms
Class RDBMS

java.lang.Object
  extended byorg.openrdf.sesame.sailimpl.rdbms.RDBMS
Direct Known Subclasses:
MySQL, Oracle, PostgreSQL, SQLServer

public class RDBMS
extends Object

A representation of an RDBMS. This class defines DBMS-specific constants and methods that are needed by the Sail classes in this package. Subclasses of this class will override specific values and methods if this is needed for that specific database.

Author:
Arjohn Kampman, Adam Skutt

Field Summary
 String BOOLEAN
          Datatype of boolean.
 int BOOLEAN_TYPE
           
 String FALSE
          Boolean value 'false'.
 String ID_INT
          Datatype for IDs (integer).
 int ID_INT_TYPE
           
 String INFOFIELD
          Datatype of fields (both key and value) in the repository info table (unicode strings of max 255 characters).
 int INFOFIELD_TYPE
           
 String LABEL
          Datatype of label of literal (arbitrary length unicode string).
 String LABEL_HASH
          Datatype of labelHash of literal (a signed 64-bit long).
 int LABEL_HASH_TYPE
           
 int LABEL_TYPE
           
 String LANGUAGE
          Datatype of language of literal.
 int LANGUAGE_TYPE
           
 String LOCALNAME
          Datatype of localname of resource.
 int LOCALNAME_TYPE
           
 int MAX_PREFIX_LENGTH
           
 String NAME
          Datatype of name of namespace.
 int NAME_TYPE
           
 String PREFIX
          Datatype of prefix of namespace.
 int PREFIX_TYPE
           
 String TRUE
          Boolean value 'true'.
 
Constructor Summary
RDBMS()
          Creates a nw RDBMS.
 
Method Summary
 void clearTable(String tableName)
          Clears a table.
 String convertBoolean(boolean b)
          Converts a boolean value to a string representation that can be used in a query for this RDBMS.
 int copyDistinctRows(String sourceTable, String targetTable)
          Copies distinct rows from one table to another (duplicates are suppressed).
 int copyRows(String sourceTable, String targetTable)
          Copies rows from one table to another.
 void createIndex(String table, String column)
          Creates an index on the specific column in the specific table.
 void createIndex(String table, String[] columns, boolean unique)
          Creates an index on the specified columns in the specified table.
static RDBMS createInstance(String jdbcUrl, String user, String passwd)
           
 void createUniqueIndex(String table, String column)
          Creates a unique index on the specified column in the specified table.
 void disconnect()
          Closes any open connections to the RDBMS.
 void dropIndex(String table, String column)
          Drops the index on the specified column name from the specified table.
 void dropIndex(String table, String[] columns)
          Drops the index on the specified columns from the specified table.
 void dropTable(String tableName)
          Drops a table.
 boolean emptyStringIsNull()
          Should return true if the database converts empty string to NULL.
 String escapeString(String s)
          Escapes any special characters in the specifed string such that it can be used in a query for this RDBMS.
 int executeUpdate(String query)
          Executes an update query.
 Connection getConnection()
          Gets a connection to the RDBMS.
 String getIndexName(String table, String column)
          Creates an index name based on the name of the column and table that it's supposed to index.
 String getIndexName(String table, String[] columns)
          Creates an index name based on the name of the columns and table that it's supposed to index.
 String getPatternMatchExpr(String pattern, boolean caseSensitive)
           
 String getPatternMatchOperator(boolean caseSensitive)
           
 String getSearchStringEscape()
          Returns the character string that can be used to escape special characters in string patterns.
 void optimizeTable(String tableName)
          Optimizes a table.
 void optimizeTable(String tableName, int modifiedRowsCount)
          Optimizes a table.
 boolean queryHasResults(String query)
          Evaluates the specific query and check whether it has any results.
 void renameTable(String currentTableName, String newTableName)
          Renames a table.
 void renameTableColumn(String tableName, String currentColumnName, String newColumnName, String columnSignature)
           
 void setConnectionInfo(String jdbcUrl, String user, String password)
          Sets the information that is required for connecting to the RDBMS.
 boolean supportsLikeEscapeClause()
          Indicates whether the database supports LIKE "..."
 boolean supportsPatternMatches(boolean caseSensitive)
           
 boolean tableExists(String tableName)
          Checks whether a table with the specified name exists.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ID_INT

public String ID_INT
Datatype for IDs (integer).


ID_INT_TYPE

public int ID_INT_TYPE

LOCALNAME

public String LOCALNAME
Datatype of localname of resource.


LOCALNAME_TYPE

public int LOCALNAME_TYPE

LANGUAGE

public String LANGUAGE
Datatype of language of literal.


LANGUAGE_TYPE

public int LANGUAGE_TYPE

LABEL

public String LABEL
Datatype of label of literal (arbitrary length unicode string).


LABEL_TYPE

public int LABEL_TYPE

LABEL_HASH

public String LABEL_HASH
Datatype of labelHash of literal (a signed 64-bit long).


LABEL_HASH_TYPE

public int LABEL_HASH_TYPE

PREFIX

public String PREFIX
Datatype of prefix of namespace.


PREFIX_TYPE

public int PREFIX_TYPE

MAX_PREFIX_LENGTH

public int MAX_PREFIX_LENGTH

NAME

public String NAME
Datatype of name of namespace.


NAME_TYPE

public int NAME_TYPE

BOOLEAN

public String BOOLEAN
Datatype of boolean.


BOOLEAN_TYPE

public int BOOLEAN_TYPE

TRUE

public String TRUE
Boolean value 'true'.


FALSE

public String FALSE
Boolean value 'false'.


INFOFIELD

public String INFOFIELD
Datatype of fields (both key and value) in the repository info table (unicode strings of max 255 characters).


INFOFIELD_TYPE

public int INFOFIELD_TYPE
Constructor Detail

RDBMS

public RDBMS()
Creates a nw RDBMS.

Method Detail

createInstance

public static RDBMS createInstance(String jdbcUrl,
                                   String user,
                                   String passwd)
                            throws SQLException
Throws:
SQLException

setConnectionInfo

public void setConnectionInfo(String jdbcUrl,
                              String user,
                              String password)
                       throws SQLException
Sets the information that is required for connecting to the RDBMS.

Throws:
SQLException

disconnect

public void disconnect()
Closes any open connections to the RDBMS.


getConnection

public Connection getConnection()
                         throws SQLException
Gets a connection to the RDBMS.

Throws:
SQLException

executeUpdate

public int executeUpdate(String query)
                  throws SQLException
Executes an update query.

Returns:
The return value of the update (e.g. number of affected rows).
Throws:
SQLException

queryHasResults

public boolean queryHasResults(String query)
                        throws SQLException
Evaluates the specific query and check whether it has any results.

Throws:
SQLException

createIndex

public void createIndex(String table,
                        String column)
                 throws SQLException
Creates an index on the specific column in the specific table.

Parameters:
table - The table name.
column - The column name.
Throws:
SQLException

createUniqueIndex

public void createUniqueIndex(String table,
                              String column)
                       throws SQLException
Creates a unique index on the specified column in the specified table.

Parameters:
table - The table name.
column - The column name.
Throws:
SQLException

createIndex

public void createIndex(String table,
                        String[] columns,
                        boolean unique)
                 throws SQLException
Creates an index on the specified columns in the specified table.

Parameters:
table - The table name.
columns - The column names
unique - Flag indicating whether the index should be a unique index.
Throws:
SQLException

dropIndex

public void dropIndex(String table,
                      String column)
               throws SQLException
Drops the index on the specified column name from the specified table.

Parameters:
table - The table name.
column - The column name.
Throws:
SQLException

dropIndex

public void dropIndex(String table,
                      String[] columns)
               throws SQLException
Drops the index on the specified columns from the specified table.

Parameters:
table - The table name.
columns - The column names.
Throws:
SQLException

getIndexName

public String getIndexName(String table,
                           String column)
Creates an index name based on the name of the column and table that it's supposed to index.


getIndexName

public String getIndexName(String table,
                           String[] columns)
Creates an index name based on the name of the columns and table that it's supposed to index.


tableExists

public boolean tableExists(String tableName)
                    throws SQLException
Checks whether a table with the specified name exists.

Throws:
SQLException

optimizeTable

public void optimizeTable(String tableName,
                          int modifiedRowsCount)
                   throws SQLException
Optimizes a table. The actual action taken depends on the database.

Throws:
SQLException

optimizeTable

public void optimizeTable(String tableName)
                   throws SQLException
Optimizes a table. The actual action taken depends on the database.

Throws:
SQLException

clearTable

public final void clearTable(String tableName)
                      throws SQLException
Clears a table.

Throws:
SQLException

dropTable

public final void dropTable(String tableName)
                     throws SQLException
Drops a table.

Throws:
SQLException

renameTable

public final void renameTable(String currentTableName,
                              String newTableName)
                       throws SQLException
Renames a table.

Throws:
SQLException

renameTableColumn

public void renameTableColumn(String tableName,
                              String currentColumnName,
                              String newColumnName,
                              String columnSignature)
                       throws SQLException
Throws:
SQLException

copyRows

public int copyRows(String sourceTable,
                    String targetTable)
             throws SQLException
Copies rows from one table to another.

Returns:
the number of rows that were copied.
Throws:
SQLException

copyDistinctRows

public int copyDistinctRows(String sourceTable,
                            String targetTable)
                     throws SQLException
Copies distinct rows from one table to another (duplicates are suppressed).

Returns:
the number of rows that were copied.
Throws:
SQLException

convertBoolean

public String convertBoolean(boolean b)
Converts a boolean value to a string representation that can be used in a query for this RDBMS.


escapeString

public String escapeString(String s)
Escapes any special characters in the specifed string such that it can be used in a query for this RDBMS.

Returns:
The original string with escape codes for any special characters.

emptyStringIsNull

public boolean emptyStringIsNull()
Should return true if the database converts empty string to NULL. Default return value is false.


supportsPatternMatches

public boolean supportsPatternMatches(boolean caseSensitive)

getPatternMatchOperator

public String getPatternMatchOperator(boolean caseSensitive)

getPatternMatchExpr

public String getPatternMatchExpr(String pattern,
                                  boolean caseSensitive)

supportsLikeEscapeClause

public boolean supportsLikeEscapeClause()
Indicates whether the database supports LIKE "..." ESCAPE '\' constructions.


getSearchStringEscape

public String getSearchStringEscape()
Returns the character string that can be used to escape special characters in string patterns.



Copyright © 2002-2006 Aduna BV, GNU LGPL License applies.