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.... :-)
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.