use of io.requery.PersistenceException in project requery by requery.
the class SchemaModifier method createQueryBuilder.
private QueryBuilder createQueryBuilder() {
if (queryOptions == null) {
try (Connection connection = getConnection()) {
String quoteIdentifier = connection.getMetaData().getIdentifierQuoteString();
queryOptions = new QueryBuilder.Options(quoteIdentifier, true, configuration.getTableTransformer(), configuration.getColumnTransformer(), configuration.getQuoteTableNames(), configuration.getQuoteColumnNames());
} catch (SQLException e) {
throw new PersistenceException(e);
}
}
return new QueryBuilder(queryOptions);
}
use of io.requery.PersistenceException in project requery by requery.
the class EntityDataStore method checkConnectionMetadata.
protected void checkConnectionMetadata() {
synchronized (configuration) {
// only done once metadata assumed to be the same for every connection
if (!metadataChecked) {
try (Connection connection = context.getConnection()) {
DatabaseMetaData metadata = connection.getMetaData();
if (!metadata.supportsTransactions()) {
transactionMode = TransactionMode.NONE;
}
supportsBatchUpdates = metadata.supportsBatchUpdates();
String quoteIdentifier = metadata.getIdentifierQuoteString();
queryOptions = new QueryBuilder.Options(quoteIdentifier, true, configuration.getTableTransformer(), configuration.getColumnTransformer(), configuration.getQuoteTableNames(), configuration.getQuoteColumnNames());
metadataChecked = true;
} catch (SQLException e) {
throw new PersistenceException(e);
}
}
}
}
use of io.requery.PersistenceException in project requery by requery.
the class PlatformFromConnection method apply.
@Override
public Platform apply(Connection connection) {
Platform platform;
String product;
try {
product = connection.getMetaData().getDatabaseProductName();
} catch (SQLException e) {
throw new PersistenceException(e);
}
if (product.contains("PostgreSQL")) {
platform = new PostgresSQL();
} else if (product.contains("SQLite")) {
platform = new SQLite();
} else if (product.contains("MySQL")) {
platform = new MySQL();
} else if (product.contains("H2")) {
platform = new H2();
} else if (product.contains("HSQL Database Engine")) {
platform = new HSQL();
} else if (product.contains("Apache Derby")) {
platform = new Derby();
} else if (product.contains("Oracle")) {
platform = new Oracle();
} else if (product.contains("Microsoft SQL Server")) {
platform = new SQLServer();
} else {
platform = new Generic();
}
return platform;
}
Aggregations