use of org.firebirdsql.gds.ng.FbDatabase in project jaybird by FirebirdSQL.
the class FBManager method createDatabase.
// Meaningful management methods
@Override
public void createDatabase(String fileName, String user, String password) throws Exception {
try {
IConnectionProperties connectionProperties = createDefaultConnectionProperties(user, password);
connectionProperties.setDatabaseName(fileName);
FbDatabase db = dbFactory.connect(connectionProperties);
db.attach();
// otherwise exit, database already exists
if (forceCreate)
db.dropDatabase();
else {
db.close();
// database exists, don't wipe it out.
return;
}
} catch (SQLException e) {
// we ignore it
}
try {
IConnectionProperties connectionProperties = createDefaultConnectionProperties(user, password);
connectionProperties.setDatabaseName(fileName);
connectionProperties.setConnectionDialect((short) dialect);
if (getPageSize() != -1) {
connectionProperties.getExtraDatabaseParameters().addArgument(ISCConstants.isc_dpb_page_size, getPageSize());
}
try (FbDatabase db = dbFactory.connect(connectionProperties)) {
db.createDatabase();
}
} catch (Exception e) {
log.error("Exception creating database", e);
throw e;
}
}
use of org.firebirdsql.gds.ng.FbDatabase in project jaybird by FirebirdSQL.
the class FBManager method isDatabaseExists.
@Override
public boolean isDatabaseExists(String fileName, String user, String password) throws Exception {
try {
IConnectionProperties connectionProperties = createDefaultConnectionProperties(user, password);
connectionProperties.setDatabaseName(fileName);
FbDatabase db = dbFactory.connect(connectionProperties);
db.attach();
db.close();
return true;
} catch (Exception e) {
return false;
}
}
Aggregations