Tabnine Logo
Dialect
Code IndexAdd Tabnine to your IDE (free)

How to use
Dialect
in
org.sonar.db.dialect

Best Java code snippets using org.sonar.db.dialect.Dialect (Showing top 20 results out of 315)

origin: SonarSource/sonarqube

@Override
public String generateSqlType(Dialect dialect) {
 switch (dialect.getId()) {
  case PostgreSql.ID:
  case MySql.ID:
  case H2.ID:
   return "INTEGER";
  case MsSql.ID:
   return "INT";
  case Oracle.ID:
   return "NUMBER(38,0)";
  default:
   throw new IllegalArgumentException("Unsupported dialect id " + dialect.getId());
 }
}
origin: SonarSource/sonarqube

MyBatisConfBuilder(Database database) {
 this.conf = new Configuration();
 this.conf.setEnvironment(new Environment("production", createTransactionFactory(), database.getDataSource()));
 this.conf.setUseGeneratedKeys(true);
 this.conf.setLazyLoadingEnabled(false);
 this.conf.setJdbcTypeForNull(JdbcType.NULL);
 Dialect dialect = database.getDialect();
 this.conf.setDatabaseId(dialect.getId());
 this.conf.getVariables().setProperty("_true", dialect.getTrueSqlValue());
 this.conf.getVariables().setProperty("_false", dialect.getFalseSqlValue());
 this.conf.getVariables().setProperty("_from_dual", dialect.getSqlFromDual());
 this.conf.getVariables().setProperty("_scrollFetchSize", String.valueOf(dialect.getScrollDefaultFetchSize()));
 this.conf.setLocalCacheScope(LocalCacheScope.STATEMENT);
}
origin: SonarSource/sonarqube

@VisibleForTesting
void initSettings() {
 properties = new Properties();
 completeProperties(settings, properties, SONAR_JDBC);
 completeDefaultProperty(properties, JDBC_URL.getKey(), DEFAULT_URL);
 doCompleteProperties(properties);
 dialect = DialectUtils.find(properties.getProperty(SONAR_JDBC_DIALECT), properties.getProperty(JDBC_URL.getKey()));
 properties.setProperty(SONAR_JDBC_DRIVER, dialect.getDefaultDriverClassName());
}
origin: SonarSource/sonarqube

private void appendDefaultValue(StringBuilder sql, ColumnDef columnDef) {
 Object defaultValue = columnDef.getDefaultValue();
 if (defaultValue != null) {
  sql.append(" DEFAULT ");
  if (defaultValue instanceof String) {
   sql.append(format("'%s'", defaultValue));
  } else if (defaultValue instanceof Boolean) {
   sql.append((boolean) defaultValue ? dialect.getTrueSqlValue() : dialect.getFalseSqlValue());
  } else {
   sql.append(defaultValue);
  }
 }
}
origin: SonarSource/sonarqube

private void initDataSource() throws Exception {
 // but it's correctly caught by start()
 LOG.info("Create JDBC data source for {}", properties.getProperty(JDBC_URL.getKey()), DEFAULT_URL);
 BasicDataSource basicDataSource = BasicDataSourceFactory.createDataSource(extractCommonsDbcpProperties(properties));
 datasource = new ProfiledDataSource(basicDataSource, NullConnectionInterceptor.INSTANCE);
 datasource.setConnectionInitSqls(dialect.getConnectionInitStatements());
 datasource.setValidationQuery(dialect.getValidationQuery());
 enableSqlLogging(datasource, logbackHelper.getLoggerLevel("sql") == Level.TRACE);
}
origin: SonarSource/sonarqube

 public static SelectImpl create(Database db, Connection connection, String sql) throws SQLException {
  // TODO use DbClient#newScrollingSelectStatement()
  PreparedStatement pstmt = connection.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
  pstmt.setFetchSize(db.getDialect().getScrollDefaultFetchSize());
  return new SelectImpl(pstmt);
 }
}
origin: SonarSource/sonarqube

public CleanupDisabledUsers(Database db, System2 system2) {
 super(db);
 this.falseValue = db.getDialect().getFalseSqlValue();
 this.system2 = system2;
}
origin: SonarSource/sonarqube

private void addColumn(StringBuilder sql, ColumnDef columnDef) {
 sql.append(columnDef.getName()).append(" ").append(columnDef.generateSqlType(dialect));
 Object defaultValue = columnDef.getDefaultValue();
 if (defaultValue != null) {
  sql.append(" DEFAULT ");
  // TODO remove duplication with CreateTableBuilder
  if (defaultValue instanceof String) {
   sql.append(format("'%s'", defaultValue));
  } else if (defaultValue instanceof Boolean) {
   sql.append((boolean) defaultValue ? dialect.getTrueSqlValue() : dialect.getFalseSqlValue());
  } else {
   sql.append(defaultValue);
  }
 }
 sql.append(columnDef.isNullable() ? " NULL" : " NOT NULL");
}
origin: org.sonarsource.sonarqube/sonar-db

private void initDataSource() throws Exception {
 // but it's correctly caught by start()
 LOG.info("Create JDBC data source for {}", properties.getProperty(DatabaseProperties.PROP_URL, DEFAULT_URL));
 BasicDataSource basicDataSource = (BasicDataSource) BasicDataSourceFactory.createDataSource(extractCommonsDbcpProperties(properties));
 datasource = new ProfiledDataSource(basicDataSource, NullConnectionInterceptor.INSTANCE);
 datasource.setConnectionInitSqls(dialect.getConnectionInitStatements());
 datasource.setValidationQuery(dialect.getValidationQuery());
 enableSqlLogging(datasource, logbackHelper.getLoggerLevel("sql") == Level.TRACE);
}
origin: SonarSource/sonarqube

/**
 * Create a PreparedStatement for SELECT requests with scrolling of results
 */
public PreparedStatement newScrollingSelectStatement(DbSession session, String sql) {
 int fetchSize = database.getDialect().getScrollDefaultFetchSize();
 return newScrollingSelectStatement(session, sql, fetchSize);
}
origin: org.sonarsource.sonarqube/sonar-db-migration

public CleanupDisabledUsers(Database db, System2 system2) {
 super(db);
 this.falseValue = db.getDialect().getFalseSqlValue();
 this.system2 = system2;
}
origin: SonarSource/sonarqube

@Override
public String generateSqlType(Dialect dialect) {
 switch (dialect.getId()) {
  case MsSql.ID:
  case MySql.ID:
   return "DATETIME";
  case Oracle.ID:
   return "TIMESTAMP (6)";
  case H2.ID:
  case PostgreSql.ID:
   return "TIMESTAMP";
  default:
   throw new IllegalArgumentException("Unsupported dialect id " + dialect.getId());
 }
}
origin: org.sonarsource.sonarqube/sonar-db

public MyBatisConfBuilder(Database database) {
 this.conf = new Configuration();
 this.conf.setEnvironment(new Environment("production", createTransactionFactory(), database.getDataSource()));
 this.conf.setUseGeneratedKeys(true);
 this.conf.setLazyLoadingEnabled(false);
 this.conf.setJdbcTypeForNull(JdbcType.NULL);
 Dialect dialect = database.getDialect();
 this.conf.setDatabaseId(dialect.getId());
 this.conf.getVariables().setProperty("_true", dialect.getTrueSqlValue());
 this.conf.getVariables().setProperty("_false", dialect.getFalseSqlValue());
 this.conf.getVariables().setProperty("_scrollFetchSize", String.valueOf(dialect.getScrollDefaultFetchSize()));
 this.conf.setLocalCacheScope(LocalCacheScope.STATEMENT);
}
origin: org.sonarsource.sonarqube/sonar-db-migration

private void appendDefaultValue(StringBuilder sql, ColumnDef columnDef) {
 Object defaultValue = columnDef.getDefaultValue();
 if (defaultValue != null) {
  sql.append(" DEFAULT ");
  if (defaultValue instanceof String) {
   sql.append(format("'%s'", defaultValue));
  } else if (defaultValue instanceof Boolean) {
   sql.append((boolean) defaultValue ? dialect.getTrueSqlValue() : dialect.getFalseSqlValue());
  } else {
   sql.append(defaultValue);
  }
 }
}
origin: org.sonarsource.sonarqube/sonar-db-core

private void initDataSource() throws Exception {
 // but it's correctly caught by start()
 LOG.info("Create JDBC data source for {}", properties.getProperty(JDBC_URL.getKey()), DEFAULT_URL);
 BasicDataSource basicDataSource = BasicDataSourceFactory.createDataSource(extractCommonsDbcpProperties(properties));
 datasource = new ProfiledDataSource(basicDataSource, NullConnectionInterceptor.INSTANCE);
 datasource.setConnectionInitSqls(dialect.getConnectionInitStatements());
 datasource.setValidationQuery(dialect.getValidationQuery());
 enableSqlLogging(datasource, logbackHelper.getLoggerLevel("sql") == Level.TRACE);
}
origin: org.sonarsource.sonarqube/sonar-db-migration

 public static SelectImpl create(Database db, Connection connection, String sql) throws SQLException {
  // TODO use DbClient#newScrollingSelectStatement()
  PreparedStatement pstmt = connection.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
  pstmt.setFetchSize(db.getDialect().getScrollDefaultFetchSize());
  return new SelectImpl(pstmt);
 }
}
origin: org.sonarsource.sonarqube/sonar-db

@VisibleForTesting
void initSettings() {
 properties = new Properties();
 completeProperties(settings, properties, SONAR_JDBC);
 completeDefaultProperty(properties, DatabaseProperties.PROP_URL, DEFAULT_URL);
 doCompleteProperties(properties);
 dialect = DialectUtils.find(properties.getProperty(SONAR_JDBC_DIALECT), properties.getProperty(SONAR_JDBC_URL));
 properties.setProperty(DatabaseProperties.PROP_DRIVER, dialect.getDefaultDriverClassName());
}
origin: SonarSource/sonarqube

@Override
public String generateSqlType(Dialect dialect) {
 return dialect.getId().equals(Oracle.ID) ? "NUMBER (38)" : "BIGINT";
}
origin: org.sonarsource.sonarqube/sonar-db-migration

private void addColumn(StringBuilder sql, ColumnDef columnDef) {
 sql.append(columnDef.getName()).append(" ").append(columnDef.generateSqlType(dialect));
 Object defaultValue = columnDef.getDefaultValue();
 if (defaultValue != null) {
  sql.append(" DEFAULT ");
  // TODO remove duplication with CreateTableBuilder
  if (defaultValue instanceof String) {
   sql.append(format("'%s'", defaultValue));
  } else if (defaultValue instanceof Boolean) {
   sql.append((boolean) defaultValue ? dialect.getTrueSqlValue() : dialect.getFalseSqlValue());
  } else {
   sql.append(defaultValue);
  }
 }
 sql.append(columnDef.isNullable() ? " NULL" : " NOT NULL");
}
origin: org.sonarsource.sonarqube/sonar-db

/**
 * Create a PreparedStatement for SELECT requests with scrolling of results
 */
public PreparedStatement newScrollingSelectStatement(DbSession session, String sql) {
 int fetchSize = database.getDialect().getScrollDefaultFetchSize();
 return newScrollingSelectStatement(session, sql, fetchSize);
}
org.sonar.db.dialectDialect

Most used methods

  • getId
  • getFalseSqlValue
  • getScrollDefaultFetchSize
    Fetch size to be used when scrolling large result sets.
  • getTrueSqlValue
  • getConnectionInitStatements
  • getDefaultDriverClassName
  • getValidationQuery
    Query used to validate the jdbc connection.
  • supportsMigration
    Indicates whether DB migration can be perform on the DB vendor implementation associated with the cu
  • getScrollSingleRowFetchSize
    Fetch size to scroll one row at a time. It sounds strange because obviously value is 1 in most cases
  • init
    This method is called when connecting for the first time to the database.
  • matchesJdbcUrl
    Used to autodetect dialect from connection URL
  • supportsUpsert
  • matchesJdbcUrl,
  • supportsUpsert,
  • getSqlFromDual,
  • matchesJdbcURL

Popular in Java

  • Creating JSON documents from java classes using gson
  • setRequestProperty (URLConnection)
  • getResourceAsStream (ClassLoader)
  • getApplicationContext (Context)
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • Connection (java.sql)
    A connection represents a link from a Java application to a database. All SQL statements and results
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • SortedSet (java.util)
    SortedSet is a Set which iterates over its elements in a sorted order. The order is determined eithe
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now