Hi John,

I saw your reply and you have anticipated my next question... :)

I have been trying to get commons-sql to build but it only seems to be available in nightly snapshot form, and ibiblio seems to have lost jdbc20.jar, so I had to go find that and it now depends on jelly and cli but those arn't in getdpendancies so I went and got those, then it had one more compile error:

[javac] Compiling 52 source files to /home/gus/projects/commons-sql/commons-sql/target/classes
[javac] /home/gus/projects/commons-sql/commons-sql/src/java/org/apache/commons/sql/ddl/DDLBuilder.java:136: cannot access org.dom4j.io.XMLWriter
[javac] file org/dom4j/io/XMLWriter.class not found
[javac] XMLOutput output = XMLOutput.createXMLOutput(writer);


so I am looking for that class next.... google here I come again :)

You don't happen to know where I can get a known compiling package of the source (and deps?) that I can patch with your patch?

Your code below looks pretty much like what I want :). I like it, and I think I already have a class that I can put it in.

-Gus

John wrote:

We have a couple of classes that wrap OJB, so we have, uninspiringly named,
DBManager and DBManagerFactory (actually a factory and factory factory in



Just to clarify - DBManagerFactory internally creates/manages factories (can configure more than one keyed on name) that create DBManagers, which equates to a PersistenceBroker or connection. Not the best names, perhaps. Anyway, here's the code that would sync a database up to the current schema definition. The connection returned by the OJB implementation in factory.getConnection() returns a proxy wrapper that calls broker.close() on the connection close so it doesn't circument OJB's normal lifecycle. It creates a string of ddl and executes it all, which is basically how the existing sql code worked.



InputStream is = //find xml DatabaseReader reader = new DatabaseReader(); Database db = (Database) reader.parse( is );

Connection existing = factory.getConnection();

StringWriter swriter = new StringWriter();
SqlBuilder builder = SqlBuilderFactory.newSqlBuilder( def.getDatabaseType() );
builder.setWriter(swriter);
builder.alterDatabase( db, existing, false, true ); //no drops, modify colums (type/size)


DDLExecutor exec = new DDLExecutor( new ConnectionDataSource(existing) );
String sql = swriter.toString();
exec.evaluateBatch( sql );

John Marshall



===== Original Message From John <[EMAIL PROTECTED]> =====
http://nagoya.apache.org/eyebrowse/[EMAIL PROTECTED]


e.org&msgId=751212


I submitted the changes once to the list and once to one of the developers.

I


think it was Jason Van Zyl.  He seemed interested.  I think this patch was
based on the code in CVS after the jelly ddl creation was added, but I'm not
sure.  I can make the whole src package available, too.

I also posted the xsl to this list at one point because other people were
asking about it and it's mentioned in the OJB docs that such a thing should


be


possible, but I don't know if anyone ever did anything with it.  I can repost
that if you want.

We have a couple of classes that wrap OJB, so we have, uninspiringly named,
DBManager and DBManagerFactory (actually a factory and factory factory in
one). Theoretically we could swap out OJB, but mostly these classes just


keep


the configuration and access the same and allow us to add some utility stuff
based on our normal conventions.  Anyway, when the factory factory first
initializes all the stuff for one factory (database), it checks the schema.
Then the factory is free to create connections, which are PersistenceBrokers
for us.  Nothing magic, just nice to use.

John Marshall







--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to