Skip to content

Commit

Permalink
See if duplicate column definition in firebird metadata might be caus…
Browse files Browse the repository at this point in the history
…ed by the jdbc driver.
  • Loading branch information
chenson42 committed Jan 6, 2010
1 parent d0e8ff9 commit 7c666da
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 8 deletions.
39 changes: 31 additions & 8 deletions symmetric/src/main/java/org/jumpmind/symmetric/util/AppUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
import java.util.Date;
import java.util.TimeZone;

import javax.sql.DataSource;

import org.apache.commons.dbcp.BasicDataSource;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.FastDateFormat;
import org.jumpmind.symmetric.ISymmetricEngine;
Expand All @@ -40,15 +43,17 @@ public class AppUtils {

private static String serverId;

private static FastDateFormat timezoneFormatter = FastDateFormat.getInstance("Z");
private static FastDateFormat timezoneFormatter = FastDateFormat
.getInstance("Z");

/**
* Get a unique identifier that represents the JVM instance this server is
* currently running in.
*/
public static String getServerId() {
if (StringUtils.isBlank(serverId)) {
serverId = System.getProperty("runtime.symmetric.cluster.server.id", null);
serverId = System.getProperty(
"runtime.symmetric.cluster.server.id", null);
if (StringUtils.isBlank(serverId)) {
// JBoss uses this system property to identify a server in a
// cluster
Expand All @@ -64,7 +69,7 @@ public static String getServerId() {
}
return serverId;
}

public static String getHostName() {
String hostName = System.getProperty("host.name", "unknown");
try {
Expand All @@ -74,7 +79,7 @@ public static String getHostName() {
}
return hostName;
}

public static String getIpAddress() {
String ipAddress = System.getProperty("ip.address", "unknown");
try {
Expand All @@ -84,9 +89,11 @@ public static String getIpAddress() {
}
return ipAddress;
}

public static String replace(String prop, String replaceWith, String sourceString) {
return StringUtils.replace(sourceString, "$(" + prop + ")", replaceWith);

public static String replace(String prop, String replaceWith,
String sourceString) {
return StringUtils
.replace(sourceString, "$(" + prop + ")", replaceWith);
}

/**
Expand Down Expand Up @@ -143,7 +150,8 @@ public static File createTempFile(String token) throws IOException {
public static Date getLocalDateForOffset(String timezoneOffset) {
long currentTime = System.currentTimeMillis();
int myOffset = TimeZone.getDefault().getOffset(currentTime);
int theirOffset = TimeZone.getTimeZone("GMT" + timezoneOffset).getOffset(currentTime);
int theirOffset = TimeZone.getTimeZone("GMT" + timezoneOffset)
.getOffset(currentTime);
return new Date(currentTime - myOffset + theirOffset);
}

Expand All @@ -162,4 +170,19 @@ public static void sleep(long ms) {
}
}

/**
* Attempt to close all the connections to a database that a DataSource has. This method
* should not be relied upon as it only works with certain {@link DataSource} implementations.
*/
public static void resetDataSource(DataSource ds) {
if (ds instanceof BasicDataSource) {
BasicDataSource bds = (BasicDataSource) ds;
try {
bds.close();
} catch (Exception ex) {
log.warn(ex);
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.jumpmind.symmetric.service.ITriggerRouterService;
import org.jumpmind.symmetric.test.AbstractDatabaseTest;
import org.jumpmind.symmetric.test.TestConstants;
import org.jumpmind.symmetric.util.AppUtils;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.jdbc.core.JdbcTemplate;
Expand Down Expand Up @@ -117,6 +118,7 @@ public void testSchemaSyncNoChanges() throws Exception {

Thread.sleep(1000);

AppUtils.resetDataSource(getDataSource());
getConfigurationService().autoConfigDatabase(true);
service.syncTriggers();

Expand Down

0 comments on commit 7c666da

Please sign in to comment.