Like the Indian Premier League (IPL) which happens during April & May every year. Our team organizes ProGrad Premier League at the same time for all the Cricketers in our team. Our PPL schema is a complete repository of limited-over format of Cricket, that includes details like teams competing, player representing each team, scoring details, umpire details etc.
Can you help out with the below task and take our database creation to completion?
Fork this repo
Clone this repo
Practice Java JDBC - class and object, Statements, Connections and CRUD.
Upon completion, run the following commands:
git add .
git commit -m "ProGrad ID"
git push origin master
And finally, create a pull request so your ProGrad Mentor (PM) can review your work.
- Do not modify the entire code.
- Edit the code as per the instructions.
- Go to Java Resources -> src folder.
- You database connection code should exists inside the utlity package.
- Your CREATE, READ, UPDATE and DELETE code should exist inside the dao package.
- Once the progressions are completed, follow the instructions to run the application and test your code.
- Add appropriate jars to your project directory.
- To add dependencies, right click on your project, select build path - configure build path - select libraries tab - select add external jars and add the downloaded jar files.
If you haven't downloaded OJDBC driver (ojdbc6.jar), then download using this link [https://www.oracle.com/database/technologies/jdbcdriver-ucp-downloads.html]
- Right click on src folder and select new - file and name it as jdbc.properties.
- You can use the jdbc properties given below in the NOTE section.
- Create a class called as
ConnectionManager
inside the utility package. - Create a method public static Connection getConnection() which returns a connection object.
- Use the method public static Properties loadPropertiesFile() to load the jdbc properties from the jdbc.properties file.
- Create a model class called as
skill
with below attributes,- skillld - Long
- skillName - String
- Include getter and setter methods for all the attributes*
- Include a constructor with below arguments,
- public skill(skillld,skillName)
- Create a dao-class called as
skilIDAO
with below method,- public TreeMap<skill,lnteger> skillCount() - Method used to retrieve number of players having particular skill.
Hint skillCount() method returns a map with key as skill type and value as number of players in that skill. Use TreeMap to store the values in alpabetical order.
- Create a controller class called
Main
. - Create appropriate objects and call the skillCount() method.
- Refer sample out for output format.
DAO Layer - Data access layer provides the gateway to create, reterive, update or delete any data in the database. All database related operations will be performed in this layer.
Use the below code to retreive the connection details from jdbc.properties to establish connection
public static Properties loadPropertiesFile() throws Exception {
Properties prop = new Properties();
InputStream in = ConnectionManager.class.getClassLoader().getResourceAsStream("jdbc.properties");
prop.load(in);
in.close();
return prop;
}
Create a file called as jdbc.properites. To create a file right click on the application - new - file - name the file as jdbc.properties.
jdbc.properties
#JDBC properties entry for ORACLE server
driver = oracle.jdbc.OracleDriver
url=jdbc:oracle:thin:@localhost:1521:xe
username=your_username
password=your_password
Sample Output
Skill Players
All Rounder 35
Batting 31
Bowling 27
Wicket Keeping Batting 4
Happy Coding ❤️