Play framework with MySQL database Part 1
Hi folks! This is my very first article on medium and I’m going to show you about play framework and how you manipulate with MySQL databases through play framework using Scala.
What is Play framework?
So I hope you have some sort of idea about what is a framework. Basically framework is a platform to develop software applications. When it comes to Play framework its an open source web application framework which follows MVC architecture. You can use both Scala and Java with Play framework and what I’m going to use is Scala which is one of the most trending functional programming language these days.
Let’s Start
Before going to play framework directly first lets see what are the prerequisite for this and how to install those on your device.
Since we are going to use Scala, you must have installed Java 8 and SBT. If you haven’t download and install those.
Java 8 : https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html
SBT : https://www.scala-lang.org/download/scala3.html
Make sure after installing Java, you must specify corresponding environment variables.
Then download and install latest intelliJ IDEA https://www.jetbrains.com/idea/download/#section=windows
After installing intelliJ you have to install scala plugin as well. Here are the steps.


OK now the most import thing. We have to download play framework. So go to play framework site.


Then unzip it and and open that folder using intelliJ Idea. This will download all the necessary dependencies so it will take a while. If you setup the project correctly then there will a green tick mark.

Now let’s dig in to coding. Be patient awesome things going to happen.
OK before all I forgot to mention that since we are going to deal with MySQL data bases you have to install wamp server as well. Its a local host server which include the necessary packages for web development such as php, MySQL etc.
Download wamp Server : https://sourceforge.net/projects/wampserver/
Seems we are good before directly jump in to coding let me show you the folder structure of play framework. In the app folder we have controller folder for store our controllers and view folder for store scala.html views. Basically these are coming from MVC architecture.

In the app folder we have controller folder for store our controllers and view folder for store scala.html views. Basically these are coming from MVC architecture.

In conf folder we have application.conf. This is the script where we specify all the necessary database configurations such as database name, password etc.
And most importantly we have routes. So route basically specify all the necessary transitions among the views. So if you are going to declare many views then you must specify corresponding routes over here.

Then finally we have target folder and within that we have build.sbt. This is the script where we specify all the necessary dependencies such as mysql.
OK now I suppose you have some idea about play framework folder structure. Now it is time to jump coding. Excited isn’t it. Oh before that lets build this default project. So go to the play-samples-play-scala-hello-world-tutorial folder and open the terminal and type following commands.


OK now go to your browser and type http://localhost:9000/

Congratulations. So we are now good to go with play framework. Folks since this article getting bit longer I may continue this as the Play framework with MySQL databases Part 2. Now go and check it out.