de.fuberlin.wiwiss.d2rq.sql
Class ConnectedDB

java.lang.Object
  extended by de.fuberlin.wiwiss.d2rq.sql.ConnectedDB

public class ConnectedDB
extends Object

Version:
$Id: ConnectedDB.java,v 1.8 2006/11/01 15:26:58 cyganiak Exp $
Author:
Richard Cyganiak (richard@cyganiak.de)

Field Summary
static int DATE_COLUMN
           
static String MySQL
           
static int NUMERIC_COLUMN
           
static String Oracle
           
static String Other
           
static String PostgreSQL
           
static int TEXT_COLUMN
           
 
Constructor Summary
ConnectedDB(String jdbcURL, String username, String password)
           
ConnectedDB(String jdbcURL, String username, String password, String expressionTranslator, boolean allowDistinct, Set textColumns, Set numericColumns, Set dateColumns, int limit)
           
 
Method Summary
 boolean allowDistinct()
          Some Databases do not handle large entries correctly.
 String backtickQuote(String s)
          Wraps s in backticks and escapes special characters to avoid SQL injection
 void close()
           
 int columnType(Attribute column)
          Returns the columnType for a given database column.
 Connection connection()
           
 String dbType()
          Reports the brand of RDBMS.
 boolean dbTypeIs(String candidateType)
           
 String doubleQuote(String s)
          Wraps s in single quotes and escapes special characters to avoid SQL injection
 boolean equals(Object otherObject)
           
 ExpressionTranslator expressionTranslator(ConstraintHandler handler)
           
 int hashCode()
           
 int limit()
           
 String quoteAttribute(Attribute attribute)
           
 String quoteRelationName(RelationName relationName)
           
 String quoteValue(String value, Attribute column)
           
 DatabaseSchemaInspector schemaInspector()
           
 String singleQuote(String s)
          Wraps s in single quotes and escapes special characters to avoid SQL injection
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MySQL

public static final String MySQL
See Also:
Constant Field Values

PostgreSQL

public static final String PostgreSQL
See Also:
Constant Field Values

Oracle

public static final String Oracle
See Also:
Constant Field Values

Other

public static final String Other
See Also:
Constant Field Values

TEXT_COLUMN

public static final int TEXT_COLUMN
See Also:
Constant Field Values

NUMERIC_COLUMN

public static final int NUMERIC_COLUMN
See Also:
Constant Field Values

DATE_COLUMN

public static final int DATE_COLUMN
See Also:
Constant Field Values
Constructor Detail

ConnectedDB

public ConnectedDB(String jdbcURL,
                   String username,
                   String password)

ConnectedDB

public ConnectedDB(String jdbcURL,
                   String username,
                   String password,
                   String expressionTranslator,
                   boolean allowDistinct,
                   Set textColumns,
                   Set numericColumns,
                   Set dateColumns,
                   int limit)
Method Detail

connection

public Connection connection()

limit

public int limit()

schemaInspector

public DatabaseSchemaInspector schemaInspector()

dbType

public String dbType()
Reports the brand of RDBMS. Will currently report one of these constants:

Returns:
The brand of RDBMS

dbTypeIs

public boolean dbTypeIs(String candidateType)

columnType

public int columnType(Attribute column)
Returns the columnType for a given database column.

Returns:
Node columnType D2RQ.textColumn or D2RQ.numericColumn or D2RQ.dateColumn

singleQuote

public String singleQuote(String s)
Wraps s in single quotes and escapes special characters to avoid SQL injection


doubleQuote

public String doubleQuote(String s)
Wraps s in single quotes and escapes special characters to avoid SQL injection


backtickQuote

public String backtickQuote(String s)
Wraps s in backticks and escapes special characters to avoid SQL injection


quoteValue

public String quoteValue(String value,
                         Attribute column)

quoteAttribute

public String quoteAttribute(Attribute attribute)

quoteRelationName

public String quoteRelationName(RelationName relationName)

expressionTranslator

public ExpressionTranslator expressionTranslator(ConstraintHandler handler)

allowDistinct

public boolean allowDistinct()
Some Databases do not handle large entries correctly. For example MSAccess cuts strings larger than 256 bytes when queried with the DISTINCT keyword. TODO We would need some assertions about a database or specific columns.


close

public void close()

equals

public boolean equals(Object otherObject)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object