aspose file tools*
The moose likes Java in General and the fly likes DB schema from src Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "DB schema from src" Watch "DB schema from src" New topic
Author

DB schema from src

surlac surlacovich
Ranch Hand

Joined: Mar 12, 2013
Posts: 296

Hello Partners!
I have and application which uses database internally without any ORM (plain old sql-scripts against JDBC).
But the problem is I don't have actual database.
Is it possible to reconstruct database schema based on this SQL-scripts? The tool that will parse the source code, find SQL-scripts, determine which table contains which datatype and output a script to create database.
I know that it looks not real, but maybe someone stumbled upon the tool like this. Thanks!
Wayan Saryada
Ranch Hand

Joined: Feb 05, 2004
Posts: 105

I am not sure if a tool exists for this kind of task. I guest you have to do it manually. How many tables you have to create for this program?


Website: Learn Java by Examples
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2289
    
  49
If the sql scripts are all selects, inserts, updates etc rather than creates etc then no you almost certainly won't be able to create an exact schema.
For a start how do you know if the sql scripts you have cover every field and every table in the schema. And even if they do, you may be able to get some of the information required to construct some of the tables but you will be hard pressed to get the exact data type/field widths etc for every field in every table.
surlac surlacovich
Ranch Hand

Joined: Mar 12, 2013
Posts: 296

Wayan Saryada wrote:How many tables you have to create for this program?

~15 tables with ~10 fields each. It's not precise values because as Tony mentioned, the scripts may not cover all the fields.

Tony Docherty wrote:you may be able to get some of the information required to construct some of the tables but you will be hard pressed to get the exact data type/field widths etc for every field in every table.

So the best solution would be to run the app, see what fields are required, modify schema, drop-create table, run again to see if the script run successfully? That's crazy, but the only way I see to solve this problem.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: DB schema from src