use of com.wplatform.ddal.engine.Database in project jdbc-shards by wplatform.
the class Command method executeUpdate.
@Override
public int executeUpdate() {
Database database = session.getDatabase();
Object sync = session;
boolean callStop = true;
synchronized (sync) {
Session.Savepoint rollback = session.setSavepoint();
session.setCurrentCommand(this);
try {
while (true) {
try {
return update();
} catch (DbException e) {
throw e;
} catch (OutOfMemoryError e) {
callStop = false;
database.shutdownImmediately();
throw DbException.convert(e);
} catch (Throwable e) {
throw DbException.convert(e);
}
}
} catch (DbException e) {
e = e.addSQL(sql);
SQLException s = e.getSQLException();
if (s.getErrorCode() == ErrorCode.OUT_OF_MEMORY) {
callStop = false;
database.shutdownImmediately();
throw e;
}
if (s.getErrorCode() == ErrorCode.DEADLOCK_1) {
session.rollback();
} else {
session.rollbackTo(rollback, false);
}
throw e;
} finally {
try {
if (callStop) {
stop();
}
} finally {
}
}
}
}
use of com.wplatform.ddal.engine.Database in project jdbc-shards by wplatform.
the class JdbcDataSource method init.
public synchronized void init() {
if (inited) {
return;
}
if (StringUtils.isNullOrEmpty(this.configLocation)) {
throw new IllegalArgumentException("Property configLocation must not be null");
}
InputStream source = Utils.getResourceAsStream(configLocation);
if (source == null) {
throw new IllegalArgumentException("Can't load the configLocation resource " + configLocation);
}
XmlConfigParser parser = new XmlConfigParser(source);
Configuration configuration = parser.parse();
configuration.setProperty(SetTypes.MODE, this.dbType);
if (this.maxMemoryRows > -1) {
configuration.setProperty(SetTypes.MAX_MEMORY_ROWS, this.maxMemoryRows);
}
if (this.maxOperationMemory > -1) {
configuration.setProperty(SetTypes.MAX_OPERATION_MEMORY, this.maxOperationMemory);
}
if (this.dataSourceProvider != null) {
configuration.setDataSourceProvider(this.dataSourceProvider);
}
this.database = new Database(configuration);
inited = true;
}
Aggregations