Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

WT File

1. https://www.hackerrank.com/challenges/java-exception-handling-try-catch/problem
2. https://www.hackerrank.com/challenges/java-exception-handling/problem
3. https://www.hackerrank.com/challenges/java-inheritance-1/problem
4. https://www.hackerrank.com/challenges/java-abstract-class/problem
5. Write a program to create a portfolio using html and css
6. Write a Java program that throws an exception and catch it using a try-catch block.
7. Write a Java program to create a method that takes an integer as a parameter and
throws an exception if the number is odd.
8. Create a servlet to print username sent from html file
9. Write a program to print hit count of a server webpage
10. Create a servlet to take input and display Fibonacci series
11. Write a servlet program for servlet login and logout using cookies.
Perform a comparative analysis between Session and Cookies.
12. Write a Java program to create a method that reads a file and throws an exception if
the file is not found.

JDBC Questions

Problem Statement-13:
Write a Java program to display the employee id, age, first name and last name
using JDBC connectivity.

Test Data: ( In Database )

ID: 100, Age: 23, First: Raj, Last: SharmaID: 101, Age: 24, First: Bala, Last: SinghID:
102, Age: 25, First: Anu, Last: PriyaID: 103, Age: 26, First: Riya, Last: Khan

Expected Output:

Connecting to database...
Creating statement...
ID: 100, Age: 23, First: Raj, Last: Sharma
ID: 101, Age: 24, First: Bala, Last: Singh
ID: 102, Age: 25, First: Anu, Last: Priya
ID: 103, Age: 26, First: Riya, Last: Khan

Problem Statement 14:

Using the JDBC API and any relational database (e.g. H2) make the following queries:

create a table MOVIES with columns: id of type INTEGER AUTO INCREMENT,title of type
VARCHAR (255), genre of type VARCHAR (255),yearOfRelease of type INTEGER. Note that a
table named MOVIE may already exist. In that case, delete it.
add any three records to the MOVIES table
update one selected record (use the PreparedStatement)
delete selected record with specified id
display all other records in the database
In the task, focus on the correct use of the JDBC API. All queries can be made directly in the
main method. Use a single connection to execute all queries. However, remember to use try-
with-resources when opening a connection and creating objects such asStatement or
PreparedStatement. Also, don't worry about exception handling in this task (in case of error,
display stacktrace).
Problem Statement 15:
Implement the class MovieDAOImpl (DAO - Data Access Object). It should perform basic
database operations for the MOVIES table, the structure of which is described in Problem 2.
Assume that an object representing an open database connection comes in the constructor
of this class. Remember to use PreparedStatement where possible and close objects (usetry-
with-resources). Also implement a Movie class that represents a single row in the MOVIES
table that you will use in implementing the MovieDAOImple class.

Implement the following operations. Each of them should be represented by a separate


public method:

creating a MOVIES table


delete the MOVIES table
adding a record
delete record by identifier
update of the movie title with id data
searching for a movie by ID
download all videos
In case of an exception SQLException, make the method throw an
exceptionDatabaseActionException. This class should extend from the RuntimeException
class.

The MovieDAOImpl class should implement the following interface:

import java.util.List;
import java.util.Optional;

public interface MovieDAO {


void createTable();
void deleteTable();

void createMovie(final Movie movie);


void deleteMovie(int id);
void updateMoviesTitle(int id, String newTitle);
Optional<Movie> findMovieById(int id);
List<Movie> findAll();
}

You might also like