From derby-user-return-10457-apmail-db-derby-user-archive=db.apache.org@db.apache.org Tue Feb 03 12:51:59 2009 Return-Path: Delivered-To: apmail-db-derby-user-archive@www.apache.org Received: (qmail 49909 invoked from network); 3 Feb 2009 12:51:59 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 3 Feb 2009 12:51:59 -0000 Received: (qmail 31271 invoked by uid 500); 3 Feb 2009 12:51:54 -0000 Delivered-To: apmail-db-derby-user-archive@db.apache.org Received: (qmail 31250 invoked by uid 500); 3 Feb 2009 12:51:54 -0000 Mailing-List: contact derby-user-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Reply-To: "Derby Discussion" Delivered-To: mailing list derby-user@db.apache.org Received: (qmail 31241 invoked by uid 99); 3 Feb 2009 12:51:54 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Feb 2009 04:51:54 -0800 X-ASF-Spam-Status: No, hits=-4.0 required=10.0 tests=RCVD_IN_DNSWL_MED,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [192.18.6.24] (HELO gmp-eb-inf-2.sun.com) (192.18.6.24) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Feb 2009 12:51:46 +0000 Received: from fe-emea-10.sun.com (gmp-eb-lb-1-fe3.eu.sun.com [192.18.6.10]) by gmp-eb-inf-2.sun.com (8.13.7+Sun/8.12.9) with ESMTP id n13CpBQ0028057 for ; Tue, 3 Feb 2009 12:51:24 GMT Received: from conversion-daemon.fe-emea-10.sun.com by fe-emea-10.sun.com (Sun Java System Messaging Server 6.2-8.04 (built Feb 28 2007)) id <0KEH00501PPX8M00@fe-emea-10.sun.com> (original mail from Kristian.Waagan@Sun.COM) for derby-user@db.apache.org; Tue, 03 Feb 2009 12:51:11 +0000 (GMT) Received: from [129.159.139.223] by fe-emea-10.sun.com (Sun Java System Messaging Server 6.2-8.04 (built Feb 28 2007)) with ESMTPSA id <0KEH00FM2QD0OA30@fe-emea-10.sun.com> for derby-user@db.apache.org; Tue, 03 Feb 2009 12:51:01 +0000 (GMT) Date: Tue, 03 Feb 2009 13:50:20 +0100 From: Kristian Waagan Subject: Re: is it possible to create a schema at connection time? In-reply-to: <21808871.post@talk.nabble.com> Sender: Kristian.Waagan@Sun.COM To: Derby Discussion Message-id: <49883D8C.1020303@Sun.COM> MIME-version: 1.0 Content-type: text/plain; format=flowed; charset=ISO-8859-1 Content-transfer-encoding: 7BIT References: <21808871.post@talk.nabble.com> User-Agent: Thunderbird 2.0.0.18 (X11/20081203) X-Virus-Checked: Checked by ClamAV on apache.org DerbyNoob wrote: > Ok here is my scenario: > > I have two java applications, which are going to use the same database > (embedded as a derby server), but with 2 different schemas. I want each > application to use its own schema. Currently a application connects to the > database like this: connect 'jdbc:derby://localhost:1527/ExampleDatabase; > create = true; user = Schema1'; respectively "Schema2" . But if the > schemas Schema1 and Schema2 does not exist, the default schema app will be > used. So my question is: is it somehow possible to create a schema at > database creating time? Hello, Is it good enough to have the schema created implicitly when you create the first table? If I do this, I get a schema called 'schema1' in my database: connect 'jdbc:derby:testDB;create=true;user=schema1;password=schema1'; # Database created, schema1 does not exist. create table mytable (id int); # The table has now been created as SCHEMA1.MYTABLE. Also, do you want to use the embedded driver, or the client driver? The JDBC URL uses the client driver, but if you only need to connect to the database from within the application (same JVM process), you could also use the embedded driver. Regards, -- Kristian