Skip to content

Commit

Permalink
SYMMETRICDS-337 - cleaned up the automatic setting of query timeout t…
Browse files Browse the repository at this point in the history
…o zero
  • Loading branch information
chenson42 committed Sep 7, 2010
1 parent 3223446 commit c21667c
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 21 deletions.
Expand Up @@ -3,19 +3,19 @@
#db.driver=oracle.jdbc.driver.OracleDriver
#db.driver=org.postgresql.Driver
#db.driver=org.apache.derby.jdbc.EmbeddedDriver
db.driver=org.hsqldb.jdbcDriver
#db.driver=org.hsqldb.jdbcDriver
#db.driver=net.sourceforge.jtds.jdbc.Driver
#db.driver=com.ibm.db2.jcc.DB2Driver
#db.driver=com.informix.jdbc.IfxDriver
#db.driver=org.h2.Driver
db.driver=org.h2.Driver

# The JDBC URL used to connect to the database
#db.url=jdbc:mysql://localhost/sampleroot
#db.url=jdbc:oracle:thin:@127.0.0.1:1521:sampleroot
#db.url=jdbc:postgresql://localhost/sampleroot
#db.url=jdbc:derby:sampleroot;create=true
db.url=jdbc:hsqldb:file:sampleroot;shutdown=true
#db.url=jdbc:h2:file:sampleroot
#db.url=jdbc:hsqldb:file:sampleroot;shutdown=true
db.url=jdbc:h2:file:sampleroot
#db.url=jdbc:jtds:sqlserver://localhost:2299/sampleroot
#db.url=jdbc:db2://localhost/samproot
#db.url=jdbc:informix-sqli://localhost:9088/sampleroot:INFORMIXSERVER=ol_ids_1150_1
Expand Down
Expand Up @@ -146,8 +146,6 @@ abstract public class AbstractDbDialect implements IDbDialect {
protected LobHandler lobHandler;

protected boolean supportsTransactionViews = false;

protected int queryTimeout = 0;

protected AbstractDbDialect() {
_defaultSizes = new HashMap<Integer, String>();
Expand Down Expand Up @@ -209,11 +207,10 @@ public int getMaxTriggerNameLength() {
: MAX_SYMMETRIC_SUPPORTED_TRIGGER_SIZE;
}

public void init(Platform pf, int queryTimeout) {
public void init(Platform pf, int queryTimeout, JdbcTemplate jdbcTemplate) {
log.info("DbDialectInUse", this.getClass().getName());
this.jdbcTemplate = new JdbcTemplate(pf.getDataSource());
this.queryTimeout = queryTimeout;
this.jdbcTemplate.setQueryTimeout(queryTimeout);
this.jdbcTemplate = jdbcTemplate;
this.jdbcTemplate.setQueryTimeout(queryTimeout);
this.platform = pf;
this.identifierQuoteString = "\"";
jdbcTemplate.execute(new ConnectionCallback<Object>() {
Expand Down
Expand Up @@ -82,7 +82,6 @@ public IDbDialect getObject() throws Exception {
dialect = (AbstractDbDialect) beanFactory.getBean("msSqlDialect");
} else if (pf instanceof PostgreSqlPlatform) {
dialect = (AbstractDbDialect) beanFactory.getBean("postgresqlDialect");
queryTimeout = 0;
} else if (pf instanceof DerbyPlatform) {
dialect = (AbstractDbDialect) beanFactory.getBean("derbyDialect");
} else if (pf instanceof H2Platform) {
Expand Down Expand Up @@ -113,8 +112,7 @@ public IDbDialect getObject() throws Exception {
throw new DbNotSupportedException();
}

dialect.init(pf, queryTimeout);
jdbcTemplate.setQueryTimeout(queryTimeout);
dialect.init(pf, queryTimeout, jdbcTemplate);
dialect.setTransactionTemplate((TransactionTemplate) beanFactory
.getBean("currentTransactionTemplate"));
return dialect;
Expand Down
Expand Up @@ -27,6 +27,7 @@
import org.jumpmind.symmetric.ddl.model.Table;
import org.jumpmind.symmetric.model.Trigger;
import org.jumpmind.symmetric.model.TriggerHistory;
import org.springframework.jdbc.core.JdbcTemplate;

public class HsqlDbDialect extends AbstractEmbeddedDbDialect implements IDbDialect {

Expand All @@ -35,8 +36,8 @@ public class HsqlDbDialect extends AbstractEmbeddedDbDialect implements IDbDiale
private boolean enforceStrictSize = true;

@Override
public void init(Platform pf, int queryTimeout) {
super.init(pf, queryTimeout);
public void init(Platform pf, int queryTimeout, final JdbcTemplate jdbcTemplate) {
super.init(pf, queryTimeout, jdbcTemplate);
jdbcTemplate.update("SET WRITE_DELAY 100 MILLIS");
jdbcTemplate.update("SET PROPERTY \"hsqldb.default_table_type\" 'cached'");
jdbcTemplate.update("SET PROPERTY \"sql.enforce_strict_size\" " + enforceStrictSize);
Expand Down
Expand Up @@ -23,15 +23,19 @@
import org.jumpmind.symmetric.db.AbstractDbDialect;
import org.jumpmind.symmetric.db.BinaryEncoding;
import org.jumpmind.symmetric.db.IDbDialect;
import org.jumpmind.symmetric.ddl.Platform;
import org.jumpmind.symmetric.model.Trigger;
import org.jumpmind.symmetric.model.TriggerHistory;
import org.springframework.jdbc.core.JdbcTemplate;

public class HsqlDb2Dialect extends AbstractDbDialect implements IDbDialect {

public static String DUAL_TABLE = "DUAL";

boolean dualTableCreated = false;

@Override
public void init(Platform pf, int queryTimeout, JdbcTemplate jdbcTemplate) {
super.init(pf, queryTimeout, jdbcTemplate);
jdbcTemplate.execute("SET DATABASE DEFAULT TABLE TYPE CACHED");
}

@Override
protected boolean doesTriggerExistOnPlatform(String catalogName, String schemaName,
String tableName, String triggerName) {
Expand Down
Expand Up @@ -39,6 +39,7 @@
import org.jumpmind.symmetric.model.TriggerHistory;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.BadSqlGrammarException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.support.lob.OracleLobHandler;
import org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractor;

Expand All @@ -51,8 +52,8 @@ public class OracleDbDialect extends AbstractDbDialect implements IDbDialect {
String selectTransactionsSql;

@Override
public void init(Platform pf, int queryTimeout) {
super.init(pf, queryTimeout);
public void init(Platform pf, int queryTimeout, JdbcTemplate jdbcTemplate) {
super.init(pf, queryTimeout, jdbcTemplate);
try {
areDatabaseTransactionsPendingSince(System.currentTimeMillis());
supportsTransactionViews = true;
Expand Down
Expand Up @@ -31,9 +31,11 @@
import org.jumpmind.symmetric.db.AbstractDbDialect;
import org.jumpmind.symmetric.db.BinaryEncoding;
import org.jumpmind.symmetric.db.IDbDialect;
import org.jumpmind.symmetric.ddl.Platform;
import org.jumpmind.symmetric.ddl.model.Column;
import org.jumpmind.symmetric.model.Trigger;
import org.jumpmind.symmetric.model.TriggerHistory;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.TransactionCallbackWithoutResult;

Expand All @@ -49,6 +51,12 @@ public class PostgreSqlDbDialect extends AbstractDbDialect implements IDbDialect

private String transactionIdExpression = "null";


@Override
public void init(Platform pf, int queryTimeout, JdbcTemplate jdbcTemplate) {
super.init(pf, 0, jdbcTemplate);
}

@Override
protected void initTablesAndFunctionsForSpecificDialect() {
if (getMajorVersion() >= 8 && getMinorVersion() >= 3) {
Expand Down

0 comments on commit c21667c

Please sign in to comment.