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