• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

How to deal with the initial SQL code, which creates the database and the tables?

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I’m a beginner writing a simple console app which uses JDBC and a MySQL database.
I intend to put on Github, so that my prospective employer can have a look at it.

What I’m wondering about is where to put the DDL sql  code, which creates the database and the tables and how to turn in into a database..
At the present moment I keep it in a separate file and I use MySQL Workbench to turn the code into a database.
But what should I do if I want to put the application on Github? I can’t commit MySQL Workbench to Github. :-)

Should Java input the DDL sql code from a separate file right at the start of tha main method?  
Then I guess I would have to struggle with multiple queries executed in a single statement.

Or can I just create a Java class, which creates  the database and all the tables one by one?

And the main method should also provide the variables wiht the database url, password and user,
so that the prospective employee can easily substitute the values, right?

Still, if he doesn’t have MySQL server, he won’t be able to run it.... :-)
 
author & internet detective
Posts: 40198
816
Eclipse IDE VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Darius,
Welcome to CodeRanch!

Your prospective employer is unlikely to run your code; just look at it or pieces of it.
That said, you should write your code in a way that isn't specific to MySQL. You can test in on derby or Postgres as well to ensure it works.

I can think of three options for the SQL:
1) Put the DDL in a file with instructions to run it
2) Have your code load it automatically
3) Use an open source tool like dbunit to help load it.

 
Darius Leszek
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jeanne Boyarsky wrote:
1) Put the DDL in a file with instructions to run it



Thanks. This option looks the simplest and least time-consuming.
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic