0% found this document useful (0 votes)
37 views6 pages

Student Info Management System Code

The document is a Java program for a student information management system that allows users to add, delete, update, and search for student records in a database. It utilizes JDBC to connect to a Derby database and provides a menu-driven interface for user interactions. The program handles SQL operations and includes error handling for database actions.

Uploaded by

220902
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)
37 views6 pages

Student Info Management System Code

The document is a Java program for a student information management system that allows users to add, delete, update, and search for student records in a database. It utilizes JDBC to connect to a Derby database and provides a menu-driven interface for user interactions. The program handles SQL operations and includes error handling for database actions.

Uploaded by

220902
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

package studentinfomanagement;

import [Link];
import [Link];
import [Link];
import [Link];
import [Link].*;
import [Link];
import [Link];
import [Link].*;

public class StudentInfoManagement {


public static void main(String[] args) {
try {
Scanner in = new Scanner([Link]);
int ch;
int regno;
String sname, sadd, sclass, scourse, dob, sql;
[Link]("[Link]");
Connection con =
[Link]("jdbc:derby://localhost:1527/Student", "akshatha",
"abcd1234");
Statement stmt = [Link]();
ResultSet rs;

do {
[Link](" MENU");
[Link]("..................");
[Link]("[Link] student");
[Link]("[Link] student");
[Link]("[Link] student address specified student reocrd");
[Link]("[Link] student");
[Link]("[Link]");
[Link]("......................");
[Link]("Enter Your Choice-> ");
ch = [Link]();
switch (ch) {
case 1:
[Link](" -----Enter student deatils-----");
[Link]("[Link] : ");
regno = [Link]();
[Link]();
[Link]("Name : ");
sname = [Link]();
[Link]("DOB[yyyy-mm-dd] : ");
dob = [Link]();
[Link]("Address : ");
sadd = [Link]();
[Link]("Class : ");
sclass = [Link]();
[Link]("Course : ");
scourse = [Link]();
sql = "INSERT INTO [Link] (STREGNO, STNAME, STDOB,
STADDRESS, STCLASS, STCOURSE)VALUES (" + regno + ",'" + sname + "','" + dob + "','" + sadd
+ "','" + sclass + "','" + scourse + "')";
int result = [Link](sql);
if (result == 1) {
[Link]("Student details are saved");
} else {
[Link]("ERRoR!!! while saving student details");
}
break;
case 2:
[Link]("Enter Student Register Number: ");
regno = [Link]();
sql = "SELECT COUNT(*) FROM [Link] WHERE STREGNO=" +
regno;
rs = [Link](sql);
[Link]();
if ([Link](1) == 1) {
sql = "DELETE FROM [Link] WHERE STREGNO=" + regno;
int res = [Link](sql);
if (res == 1) {
[Link]("Student Record deleted");
} else {
[Link]("Error!!While deleting student reocrd");
}
} else {
[Link]("Student Reocrd Not Found!!!");
}
break;
case 3:
[Link]("Enter Register Number: ");
regno = [Link]();
[Link]();
sql = "SELECT COUNT(*) FROM [Link] WHERE STREGNO=" +
regno;
rs = [Link](sql);
[Link]();
if ([Link](1) == 1) {
sql = "SELECT STADDRESS FROM [Link] WHERE STREGNO=" +
regno;
rs = [Link](sql);
[Link]();
[Link]("Old Address is : " + [Link](1));
[Link]("Enter New Address ");
String add = [Link]();
sql = "UPDATE [Link] SET STADDRESS='" + add + "'WHERE
STREGNO=" + regno;
if ([Link](sql) == 1) {
[Link]("Address Updated");

} else {
[Link]("Error while Updating address");
}

} else {
[Link]("Student Record Not Found");
}
break;
case 4:
[Link]("Enter the Register No: ");
regno = [Link]();
sql = "SELECT * FROM [Link] WHERE STREGNO=" + regno;
rs = [Link](sql);
if (rs != null) {
[Link]();
[Link]("Student details are");
[Link]("...................");
[Link]("Reg No :" + [Link](1));
[Link]("Name :" + [Link](2));
[Link]("DOB :" + [Link](3));
[Link]("Address :" + [Link](4));
[Link]("Class :" + [Link](5));
[Link]("Course :" + [Link](6));
[Link]("...................");

}
break;
case 5:
[Link]();
[Link]();
[Link]("Thank You....");
return;
default:
[Link]("Wrong Choice... TRY AGAIN...");

}
} while (true);

} catch (SQLException ex) {


[Link]([Link]()).log([Link], null,
ex);
} catch (ClassNotFoundException ex) {
[Link]([Link]()).log([Link], null,
ex);
}

You might also like