This tutorial demonstrates how to develop a simple Java application that connects with a database and provides a user interface using a series of videos compiled as a playlist (Youtube). The application is kept very simple while making use of various technologies, such as Maven (Homepage). This tutorial is targeted to college or university students who studied Java but lack experience and would like to do something productive. The main idea of this tutorial is not learn Java, but to help the viewers to gain experience on various technologies that are commonly used in industry but not necessarily taught in schools or courses. One of the greatest challenges a new developer has when starting a project from scratch is finding his or her way and make use of the right technology. The playlist presented by this tutorial shows how to build a Java application that connects to a database and provides a user interface in a step-by-step fashion.
All code listed below is available at: http://java-creed-examples.googlecode.com/svn/introduction/Simple Java Database Swing Application/. Each video has its own project, with the exception of the first, and the viewers can download or view all code from the above link.
The tutorial comprises the following
DataSource(Java Doc) and Flyway (Homepage), a third party library that manages database migrations. This video demonstrates how to manage the database updates while the application develops and evolves with minimal effort.
The application shown in this tutorial is developed with Spring Tool Suite, also referred to as STS, (Download). The viewers are free to use any integrated development environment, also referred to as IDE, (Wiki), they prefer. In such event, please note that some of the commands or shortcuts may not work on a different IDE and some things may be organised differently. If you are new to Java, it is highly recommended to use the same IDE as the one used in the videos as this will simplifies your learning experience. Please note that by no means we are saying that the other IDE are not good or that STS is better than all others. For more information about how to setup your environment please follow the Setting up the Environment tutorial.
Following is a list of resources technologies used in this tutorial. These are shown in the order they appear.
Please note that the videos are recorded in HD (1080p). Make sure to use the correct resolution to make the best out of these videos as shown below.
getConnection()method. Could you explain it please? I do not know if I should even call it a path?
getConnection()method is the database URL. Here we are using H2 database (Homepage) which is saved in a local path relative to the project. The path is “
target/db“, where “
target” is the folder and “
db” is the database name. Say that you want to save the database under the directory called “
db” with the name: “
app“. Then the database connection URL will be “
jdbc:h2:db/app“. Please make sure that this directory exists as otherwise you may get an error.
com.googlecode.flyway.core.api.FlywayException: Unable to determine URL for classpath location: db/migration (ClassLoader: [email protected])
how can I fix it?
This path needs to be in your class path. Say you package is “com.mypkg”, then the folder “db” needs to be where the folder “com” is. If you are using Maven, the “db/migration” folders can be organised as shown in the video.
V1__initial_db.sqlhas an unknown type. I can’t open it with eclipse as it’s shown in your computer?
V1__initial_db.sqlis a simple text file and you should be able to open it.