Skip to content

DataStax-Academy/cday-appdev-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Application Development

Pre-requisite

To run the Application Development exercice on your laptop you must have installed :

  • JDK8+
  • Maven (3.6+)
  • an IDE like Eclipse or IntelliJ.

Setup your laptop

This session will help you to setup your laptop to do the Exercises

###1.Clone the repository where you are located the Exercices

git clone https://github.com/DataStax-Academy/cday-appdev-java.git

###2.Build the project

cd cday-appdev-java

mvn clean install

This is the output you can get :

cedricklunven@clunhost:~/dev/WORKSPACES/DATASTAX/cday-appdev-java> mvn clean install
[INFO] Scanning for projects...
...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.923 s
[INFO] Finished at: 2019-10-01T10:54:05+02:00
[INFO] ------------------------------------------------------------------------

###3.Import the Project in your IDE

Import the project as a Java project, a pom.xml has been provided to you.

Exercise 1

  • Open the class ClusterSettings. And fill the 3 constants CONTACT_POINT_1, CONTACT_POINT_2 and KEYSPACENAME as stated in the comment.

  • Open class Exercice1_ConnectAndCreateSchema and setup your connection to point to your Cluster and your DataCenter> you will have to edit the following line.

CqlSession cqlSession = CqlSession.builder().build()
  • Execute the class as a Java Application

Links that might be useful:

Exercise 2

  • Open class Exercice2_CreateSimpleStatement and define a statement to insert a new users in the tables users
SimpleStatement.builder("<YOUR_STATEMENT>").build();
  • Execute the class as a Java Application

Links that might be useful:

Exercise 3

  • Open class Exercice3_CreatePreparedStatement and define preparedStatement in the following method
private static PreparedStatement prepareStatementOnce(CqlSession cqlSession) {
  return null;
}
  • Bind the parameters to create a BoundStatement in the method
private static BoundStatement bindQuery(PreparedStatement queryInsertUser, 
            String firstName, String lastName, int age, String city, String email) {
        LOGGER.info(" + Insert {} {}", firstName, lastName);
        return null;
}
  • Execute the class as a Java Application

Links that might be useful:

After completing the exercice, you should be able to execute the request below

Exercise 4

  • Open class Exercice4_ListUsers and implements the displayUsers to log FirstName and LastName of each row.
private static void displayUsers(ResultSet rs) {
   throw new RuntimeException("Not Implemented");
}
  • Execute the class as a Java Application

Links that might be useful:

About

Application Development with Java

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages