diff options
author | James Moger <james.moger@gmail.com> | 2011-08-08 12:25:12 -0400 |
---|---|---|
committer | James Moger <james.moger@gmail.com> | 2011-08-08 12:25:12 -0400 |
commit | f44168da2824063985f8ecfa1a75f9984e8f7fb0 (patch) | |
tree | 6501b13134a5644d5560f9cb3be835c576919266 /src/com/iciql/SQLDialect.java | |
parent | d5a74dcac41eeb96a656b7033e43d51b92f75d18 (diff) | |
download | iciql-f44168da2824063985f8ecfa1a75f9984e8f7fb0.tar.gz iciql-f44168da2824063985f8ecfa1a75f9984e8f7fb0.zip |
Documentation. Moved dialects into separate package.
Diffstat (limited to 'src/com/iciql/SQLDialect.java')
-rw-r--r-- | src/com/iciql/SQLDialect.java | 126 |
1 files changed, 0 insertions, 126 deletions
diff --git a/src/com/iciql/SQLDialect.java b/src/com/iciql/SQLDialect.java index 3cb9339..8291e53 100644 --- a/src/com/iciql/SQLDialect.java +++ b/src/com/iciql/SQLDialect.java @@ -18,12 +18,8 @@ package com.iciql; import java.sql.Connection; -import java.sql.DatabaseMetaData; -import java.sql.SQLException; import com.iciql.TableDefinition.IndexDefinition; -import com.iciql.util.StatementBuilder; -import com.iciql.util.StringUtils; /** * This interface defines points where iciql can build different statements @@ -111,126 +107,4 @@ public interface SQLDialect { * @return true if they are */ boolean supportsLimitOffset(); - - /** - * Default implementation of an SQL dialect. - * Does not support merge nor index creation. - */ - public static class DefaultSQLDialect implements SQLDialect { - float databaseVersion; - String productName; - String productVersion; - - @Override - public String toString() { - return getClass().getName() + ": " + productName + " " + productVersion; - } - - @Override - public void configureDialect(Connection conn) { - loadIdentity(conn); - } - - protected void loadIdentity(Connection conn) { - try { - DatabaseMetaData data = conn.getMetaData(); - databaseVersion = Float.parseFloat(data.getDatabaseMajorVersion() + "." - + data.getDatabaseMinorVersion()); - productName = data.getDatabaseProductName(); - productVersion = data.getDatabaseProductVersion(); - } catch (SQLException e) { - throw new IciqlException(e); - } - } - - @Override - public boolean supportsMemoryTables() { - return false; - } - - @Override - public boolean supportsMerge() { - return false; - } - - @Override - public boolean supportsLimitOffset() { - return true; - } - - @Override - public String prepareTableName(String schema, String table) { - if (StringUtils.isNullOrEmpty(schema)) { - return table; - } - return schema + "." + table; - } - - @Override - public String prepareColumnName(String name) { - return name; - } - - @Override - public String prepareCreateIndex(String schema, String table, IndexDefinition index) { - throw new IciqlException("Dialect does not support index creation!"); - } - - @Override - public void appendLimit(SQLStatement stat, long limit) { - stat.appendSQL(" LIMIT " + limit); - } - - @Override - public void appendOffset(SQLStatement stat, long offset) { - stat.appendSQL(" OFFSET " + offset); - } - } - - - /** - * H2 database dialect. - */ - public static class H2Dialect extends DefaultSQLDialect { - - @Override - public boolean supportsMemoryTables() { - return true; - } - - @Override - public boolean supportsMerge() { - return true; - } - - @Override - public String prepareCreateIndex(String schema, String table, IndexDefinition index) { - StatementBuilder buff = new StatementBuilder(); - buff.append("CREATE "); - switch (index.type) { - case STANDARD: - break; - case UNIQUE: - buff.append("UNIQUE "); - break; - case HASH: - buff.append("HASH "); - break; - case UNIQUE_HASH: - buff.append("UNIQUE HASH "); - break; - } - buff.append("INDEX IF NOT EXISTS "); - buff.append(index.indexName); - buff.append(" ON "); - buff.append(table); - buff.append("("); - for (String col : index.columnNames) { - buff.appendExceptFirst(", "); - buff.append(col); - } - buff.append(")"); - return buff.toString(); - } - } } |