Return-Path: Delivered-To: apmail-db-ojb-dev-archive@www.apache.org Received: (qmail 6312 invoked from network); 21 Jan 2004 14:00:48 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 21 Jan 2004 14:00:48 -0000 Received: (qmail 97276 invoked by uid 500); 21 Jan 2004 14:00:17 -0000 Delivered-To: apmail-db-ojb-dev-archive@db.apache.org Received: (qmail 97250 invoked by uid 500); 21 Jan 2004 14:00:17 -0000 Mailing-List: contact ojb-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "OJB Developers List" Reply-To: "OJB Developers List" Delivered-To: mailing list ojb-dev@db.apache.org Received: (qmail 97178 invoked from network); 21 Jan 2004 14:00:17 -0000 Received: from unknown (HELO prosun.first.fraunhofer.de) (194.95.168.2) by daedalus.apache.org with SMTP; 21 Jan 2004 14:00:17 -0000 Received: from pille.first.gmd.de (pille [194.95.168.10]) by prosun.first.fraunhofer.de (8.12.10/8.12.10) with SMTP id i0LE0HWp015640 for ; Wed, 21 Jan 2004 15:00:17 +0100 (MET) Received: from localhost by pille.first.gmd.de (SMI-8.6/SMI-SVR4) id PAA09694; Wed, 21 Jan 2004 15:00:17 +0100 Date: Wed, 21 Jan 2004 15:00:16 +0100 (MET) From: Thomas Dudziak X-Sender: tomdz@pille To: ojb-dev@db.apache.org Subject: New utility class for db creation Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Hi folks, I just added a new class that allows to create (e.g. "create database") and initialize (e.g. "create table") a database from java using torque and the torque schemas. Usage is something like this: String srcDir = "resources/ojb"; String schemas = "*-schema.xml"; PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker(); ConnectionRepository connRep = MetadataManager.getInstance().connectionRepository(); TorqueDBHandling dbHandler = new TorqueDBHandling(connRep.getDescriptor(broker.getPBKey()), srcDir, schemas); dbHandler.createDB(); dbHandler.createTables(); I figured such a class might be useful to further automate the unit tests and eventually make them independent of each other (e.g. by creating and populating the database prior to each test). I didn't exactly know where to put the class but I thought the broker.platforms subpackage is a good place as similar implementations might be necessary for other platforms supported by OJB (e.g. MsAccess and Informix are not supported by Torque so they would need specific creation/initialization stuff) which then could be hidden by a Platform.getDbHandler and a DbHandler interface where the actual implementation is chosen by the PlatformImpls. I'll probably add stuff to populate the db from strings or files (xml, csv), as well. One problem that remains is that for most jdbc drivers the jdbc url to create a database is different from the url to manipulate an existing db. E.g. when using the ant sql task with mysql you would do this to create a db: drop database if exists testdb; create database testdb; (note the missing database name in the url). As the database url is driver specific (or at least platform specific), there is some testing necessary to determine these urls for the torque-supported platforms. Tom --------------------------------------------------------------------- To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org For additional commands, e-mail: ojb-dev-help@db.apache.org