Thanks for your reply, Dag.

Yes, your advice did help, and I generated a file containing the DDL commands :-) Many thanks!

I too had thought of invoking the main method of dblook, but then decided against it thinking that the main method is meant to be invoked by the runtime only.


From: Dag Wanvik <>
To: Derby Discussion <>
Sent: Monday, 15 October 2012 6:28 PM
Subject: Re: How to emit DDL programmatically using dblook?

On 15.10.2012 13:03, Dinesh Bajaj wrote:

I am struggling to emit DDL of a Derby database programmatically. So far, I was using dblook tool at the command prompt to generate the DDL. Now, I need to do it through code, and I can't  find a method in the dblook class that I could invoke to accomplish this task.

Sorry, if this question sounds silly.

I am not sure we have a API for this, but you could try to call dblook from your app directily:
This worked for me:

public static void main(String[] args) throws SQLException {
        Connection c = DriverManager.getConnection("jdbc:derby:wombat;create=true");
        Statement s = c.createStatement();
        s.executeUpdate("create table t (i int)");
        String args2[] = { "-d", "jdbc:derby:wombat"};

giving this on system out:

-- Timestamp: 2012-10-15 14:55:57.548
-- Source database is: wombat
-- Connection URL is: jdbc:derby:wombat
-- appendLogs: false

-- ----------------------------------------------
-- DDL Statements for tables
-- ----------------------------------------------


By proving an "-o" argument you could redirect this to a file and pick it up from your app.
Hope this helps,