0% found this document useful (0 votes)
9 views

Java Database Connectivity - CodeDoc

This is jdbc

Uploaded by

lakheraaditya03
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Java Database Connectivity - CodeDoc

This is jdbc

Uploaded by

lakheraaditya03
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Java Database Connectivity (JDBC)

1. Add Bill

This servlet handles POST requests to add a bill. It retrieves parameters (userId, amountDue,
dueDate) from the request, establishes a database connection using JDBC, prepares an SQL
statement to insert the data into the bills table, and executes the update. If the insertion is
successful, it prints a confirmation message. The code includes error handling and ensures the
database connection is properly managed.

2. Payment

This servlet handles POST requests to add a bill. It retrieves parameters (userId, amountDue,
dueDate) from the request, establishes a database connection using JDBC, prepares an SQL
statement to insert the data into the bills table, and executes the update. If the insertion is
successful, it prints a confirmation message. The code includes error handling and ensures the
database connection is properly managed.
3. View Bill

This servlet handles POST requests to view a bill. It retrieves the userId parameter from the request,
establishes a JDBC connection, and prepares an SQL query to fetch bill details where the status is
‘Pending’. The query is executed, and if a matching record is found, the bill details are processed. The
code includes error handling and ensures the database connection is properly managed.

4. Pay Bill

This servlet handles POST requests to pay a bill. It retrieves the billId parameter from the request,
establishes a JDBC connection, and prepares an SQL query to update the bill’s status to ‘Paid’ and set
the payment date. The query is executed, and if the update is successful, it redirects to a success
page. The code includes error handling and ensures the database connection is properly managed.
5. Admin Login

This servlet handles POST requests for admin login. It retrieves email and password parameters from
the request, establishes a JDBC connection, and prepares an SQL query to check the credentials
against the admin table. If a match is found, the user is validated. The code includes error handling
and ensures the database connection is properly managed.

6. Delete Complaint

This servlet handles POST requests to delete a complaint. It retrieves the complaintId parameter
from the request, establishes a JDBC connection, and prepares an SQL statement to delete the
complaint from the complaints table where the consumer_number matches the given ID. The query
is executed, and if the deletion is successful, it redirects to the admin dashboard. The code includes
error handling and ensures the database connection is properly managed.

You might also like