Package net.sf.hajdbc.dialect

Examples of net.sf.hajdbc.dialect.Dialect


   * @see net.sf.hajdbc.sync.SynchronizationSupport#dropUniqueConstraints()
   */
  @Override
  public void dropUniqueConstraints() throws SQLException
  {
    Dialect dialect = this.context.getDialect();

    Connection connection = this.context.getConnection(this.context.getTargetDatabase());
    boolean autoCommit = connection.getAutoCommit();
    try
    {
      connection.setAutoCommit(true);
      Statement statement = connection.createStatement();
      try
      {
        for (TableProperties table: this.context.getTargetDatabaseProperties().getTables())
        {
          for (UniqueConstraint constraint: table.getUniqueConstraints())
          {
            String sql = dialect.getDropUniqueConstraintSQL(constraint);
           
            this.logger.log(Level.DEBUG, sql);
           
            statement.addBatch(sql);
          }
View Full Code Here


   * @see net.sf.hajdbc.sync.SynchronizationSupport#restoreUniqueConstraints()
   */
  @Override
  public void restoreUniqueConstraints() throws SQLException
  {
    Dialect dialect = this.context.getDialect();

    Connection connection = this.context.getConnection(this.context.getTargetDatabase());
    boolean autoCommit = connection.getAutoCommit();
    try
    {
      connection.setAutoCommit(true);
     
      Statement statement = connection.createStatement();
      try
      {
        for (TableProperties table: this.context.getSourceDatabaseProperties().getTables())
        {
          // Drop unique constraints on the current table
          for (UniqueConstraint constraint: table.getUniqueConstraints())
          {
            String sql = dialect.getCreateUniqueConstraintSQL(constraint);
           
            this.logger.log(Level.DEBUG, sql);
           
            statement.addBatch(sql);
          }
View Full Code Here

    String sql = rawSQL;
   
    long now = System.currentTimeMillis();
   
    DatabaseCluster<Z, D> cluster = this.getDatabaseCluster();
    Dialect dialect = cluster.getDialect();
   
    if (cluster.isCurrentTimestampEvaluationEnabled())
    {
      sql = dialect.evaluateCurrentTimestamp(sql, new java.sql.Timestamp(now));
    }
   
    if (cluster.isCurrentDateEvaluationEnabled())
    {
      sql = dialect.evaluateCurrentDate(sql, new java.sql.Date(now));
    }
   
    if (cluster.isCurrentTimeEvaluationEnabled())
    {
      sql = dialect.evaluateCurrentTime(sql, new java.sql.Time(now));
    }
   
    if (cluster.isRandEvaluationEnabled())
    {
      sql = dialect.evaluateRand(sql);
    }
   
    return sql;
  }
View Full Code Here

  }
 
  @Test
  public void indicatesFailure()
  {
    Dialect dialect = mock(Dialect.class);
   
    assertFalse(this.factory.indicatesFailure(new IOException(), dialect));

    Mockito.verifyNoMoreInteractions(dialect);
  }
View Full Code Here

  }
 
  @Test
  public void indicatesFailure()
  {
    Dialect dialect = mock(Dialect.class);
    XAException exception = new XAException();
   
    when(dialect.indicatesFailure(exception)).thenReturn(true);
   
    boolean result = this.factory.indicatesFailure(exception, dialect);
   
    assertTrue(result);
  }
View Full Code Here

  }
 
  @Test
  public void indicatesFailure()
  {
    Dialect dialect = mock(Dialect.class);
    SQLException exception = new SQLException();
    SQLException nextException = new SQLException();
   
    when(dialect.indicatesFailure(exception)).thenReturn(true);
   
    boolean result = this.factory.indicatesFailure(exception, dialect);
   
    assertTrue(result);

    reset(dialect);
   
    exception.setNextException(nextException);
   
    when(dialect.indicatesFailure(exception)).thenReturn(false);
    when(dialect.indicatesFailure(nextException)).thenReturn(true);
   
    result = this.factory.indicatesFailure(exception, dialect);
   
    assertTrue(result);
  }
View Full Code Here

   */
  @Override
  public DatabaseProperties getDatabaseProperties(D database, Connection connection) throws SQLException
  {
    DatabaseMetaData metaData = connection.getMetaData();
    Dialect dialect = this.cluster.getDialect();
    return new LazyDatabaseProperties(new SimpleDatabaseMetaDataProvider(metaData), dialect);
  }
View Full Code Here

  public <Z, D extends Database<Z>, T, R, E extends Exception> SortedMap<D, R> invoke(ProxyFactory<Z, D, T, E> factory, Invoker<Z, D, T, R, E> invoker) throws E
  {
    DatabaseCluster<Z, D> cluster = factory.getDatabaseCluster();
    ExceptionFactory<E> exceptionFactory = factory.getExceptionFactory();
    Balancer<Z, D> balancer = cluster.getBalancer();
    Dialect dialect = cluster.getDialect();
    StateManager stateManager = cluster.getStateManager();
   
    while (true)
    {
      D database = this.selector.selectDatabase(balancer);
View Full Code Here

  @Override
  public <Z, D extends Database<Z>, T, R, E extends Exception> SortedMap<D, R> invoke(ProxyFactory<Z, D, T, E> factory, Invoker<Z, D, T, R, E> invoker) throws E
  {
    DatabaseCluster<Z, D> cluster = factory.getDatabaseCluster();
    Balancer<Z, D> balancer = cluster.getBalancer();
    Dialect dialect = cluster.getDialect();
    StateManager stateManager = cluster.getStateManager();

    for (Map.Entry<D, T> entry: factory.entries())
    {
      D database = entry.getKey();
View Full Code Here

  }
 
  private synchronized void setDatabaseProperties(Connection connection) throws SQLException
  {
    DatabaseMetaData metaData = connection.getMetaData();
    Dialect dialect = this.cluster.getDialect();
    this.properties = new EagerDatabaseProperties(metaData, dialect);
  }
View Full Code Here

TOP

Related Classes of net.sf.hajdbc.dialect.Dialect

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.