DatabaseMetaData dmd = con.getMetaData();
if (DBVendorTypeHelper.requireUpperCaseSchema(dmd)) {
userSchema = dmd.getUserName().trim().toUpperCase();
}
ConnectionProvider cp = new ConnectionProvider(con, dmd.getDriverName().trim());
if (userSchema != null) {
cp.setSchema(userSchema);
}
OutputStream outstream = null;
try {
SchemaElementImpl outSchemaImpl = new SchemaElementImpl(cp);
SchemaElement schemaElement = new SchemaElement(outSchemaImpl);
schemaElement.setName(DBIdentifier.create(generatedSchemaName));
if(dmd.getDatabaseProductName().compareToIgnoreCase("MYSQL") == 0)
outSchemaImpl.initTables(cp, new LinkedList(tables), new LinkedList(), true);
else
outSchemaImpl.initTables(cp, new LinkedList(tables), new LinkedList(), false);
outstream = new FileOutputStream(
new File(classout,
new StringBuffer(generatedSchemaName)
.append(DBSCHEMA_EXTENSION).toString()));
// XXX Unfortunately, if SchemaElement.save gets an
// IOException, it prints the stack trace but does not
// let us handle it :-(
schemaElement.save(outstream);
} catch (IOException ex) {
// Catch FileNotFound, etc.
throw JDOCodeGeneratorHelper.createGeneratorException(
"CMG.CannotSaveDBSchema", bundle, ex); // NOI18N
} finally {
cp.closeConnection();
try {
if (outstream != null) {
outstream.close();
}
} catch (IOException ex) {