Package Jdbcdemo Corrected
Package Jdbcdemo Corrected
Course.java
--------------------------------
public Course() {
super();
}
public Course(String crid, String crsName, int duration, int fee) {
super();
this.crid = crid;
this.crsName = crsName;
this.duration = duration;
this.fee = fee;
return crid;
this.crid = crid;
return crsName;
this.crsName = crsName;
return duration;
this.duration = duration;
return fee;
}
public void setFee(int fee) {
this.fee = fee;
@Override
courseCURD.java
----------------------------
package jdbcdemo;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Scanner;
if(sts)
else
String crid="cr";
//code
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
//establish Connection
String user="wcf20jan";
String pwd="wcf20jan";
PreparedStatement ps = con.prepareStatement(qry);
//execute statement
if(res.next())
crid = crid+res.getInt("crid");
//close connection
con.close();
}catch(Exception ex) {
System.out.println(ex.getMessage());
return crid;
//code
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
//establish Connection
String user="wcf20jan";
String pwd="wcf20jan";
PreparedStatement ps = con.prepareStatement(qry);
ps.setString(1,c.getCrid());
ps.setString(2,c.getCrsName());
ps.setInt(3,c.getDuration());
ps.setInt(4, c.getFee());
//execute statement
//process result
if(recCount==1)
sts = true;
//close connection
con.close();
catch(Exception ex) {
System.out.println(ex.getMessage());
return sts;
Employee.java
------------------------------
package jdbcdemo;
public Employee() {
empid = 9999;
this.empid = empid;
this.name = name;
this.salary = salary;
// code
try {
} catch (CloneNotSupportedException e) {
return emp;
@Override
EmployeeCURD.java
-------------------------------------------
package jdbcdemo;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Scanner;
else
int eid=0;
//code
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
//establish Connection
String user="wcf20jan";
String pwd="wcf20jan";
PreparedStatement ps = con.prepareStatement(qry);
//execute statement
//process result
if(res.next())
eid = res.getInt("eid");
//close connection
con.close();
}catch(Exception ex) {
System.out.println(ex.getMessage());
return eid;
//code
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
//establish Connection
String user="wcf20jan";
String pwd="wcf20jan";
PreparedStatement ps = con.prepareStatement(qry);
ps.setInt(1,e.empid);
ps.setString(2,e.name);
ps.setInt(3,e.salary);
//execute statement
//process result
if(recCount==1)
sts = true;
//close connection
con.close();
}
catch(Exception ex) {
System.out.println(ex.getMessage());
return sts;
Student.java
-------------------------------
/**
*/
package jdbcdemo;
public Student() {
super();
super();
this.rno = rno;
this.name = name;
this.score = score;
return rno;
this.rno = rno;
return name;
this.name = name;
return score;
this.score = score;
@Override
return "Student [rno=" + rno + ", name=" + name + ", score=" + score + "]";
}
StudentCURD.java
-----------------------------------------
/**
*/
package jdbcdemo;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.util.Scanner;
if(sts)
else
}
private boolean insertSt(Student s) {
//code
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
//Establish Connection
String user="wcf20jan";
String pwd="wcf20jan";
PreparedStatement ps = con.prepareStatement(qry);
ps.setInt(1,s.getRno());
ps.setString(2,s.getName());
ps.setInt(3,s.getScore());
//Execute
//process result
if(recCount==1)
sts = true;
catch(Exception ex) {
System.out.println(ex.getMessage());
return sts;
}