unable to insert data into database
hello.i have a problem in inserting data into database.i have used two prepared statement.one for retrieving the eid based on ename and the other is inserting data into database based on this ename.but it displays a message that "Sorry! Could Not Enter Details into Time Sheet!".can any one help me plz.
empbeans.java:
public void sheet() {
ename = util.getSession().getAttribute("ename").toString();
boolean done = userdao.sheet(pid, ptime, rtime, workdone,ename);
if (done) {
pid = ptime = rtime = 0;
workdone = leavedate = "";
message = "Entered details into Time Sheet Successfully!";
} else {
message = "Sorry! Could Not Enter Details into Time Sheet!";
}
}
userdao.java
public static boolean sheet(int pid,int ptime,int rtime,String workdone,String ename) {
Connection con = null;
PreparedStatement ps1 = null;
PreparedStatement ps2=null;
ResultSet rs=null;
try {
con = Database.getConnection();
ps1=con.prepareStatement("select eid from employee where ename=?");
ps1.setString(1, ename);
rs=ps1.executeQuery();
ps2 = con.prepareStatement(
"insert into emp_timesheet values(?,sysdate,?,?,?,?)");
ps2.setInt(1,rs.getInt(1));
ps2.setInt(2, pid);
ps2.setInt(3, ptime);
ps2.setInt(4, rtime);
ps2.setString(5, workdone);
int count = ps2.executeUpdate();
return count == 1;
} catch (Exception ex) {
System.out.println("Error in inserting into time sheet -->" + ex.getMessage());
return false;
} finally {
Database.close(con);
}
}
View Answers
Ads
Related Tutorials/Questions & Answers:
unable to insert data into database
unable to
insert data into
database hello.i have a problem in inserting
data into database.i have used two prepared statement.one for retrieving the eid based on ename and the other is inserting
data into
database based
unable to insert data into database
unable to
insert data into
database hello.i have a problem in inserting
data into database.i have used two prepared statement.one for retrieving the eid based on ename and the other is inserting
data into
database based
Advertisements
unable to insert data into database
unable to
insert data into
database hello.i have a problem in inserting
data into database.i have used two prepared statement.one for retrieving the eid based on ename and the other is inserting
data into
database based
unable to insert data into database
unable to
insert data into
database hello.i have a problem in inserting
data into database.i have used two prepared statement.one for retrieving the eid based on ename and the other is inserting
data into
database based
insert data into database
insert data into database hi,thanks for reply
just i am doing... and studentmaster is the
database table name.
i am using same details.
Now give the
data into the jsp page that
data stored into the database.Here the error
database is connected but not insert the data
database is connected but not
insert the data hi,
i am getting connected to database.Retrive the
data also but cannot
insert the
data into
database...=con.prepareStatement("
insert into studentmaster(slno) values('"+batch+"')");
i
insert data into database
insert data into database type Exception report
message...)Go to the start->Control Panel->Administrative Tools->
data sources.
2... selecting the driver, click finish button.
4)Then give
Data Source Name
insert data in the database using checkbox
insert data in the
database using checkbox i am fetching
data from the
database using servlet on the jsp page and there is checkbox corresponding... should i
insert only checked
data into
database on submission.
We
Question about "Insert text file data into Database"
Question about "
Insert text file
data into
Database" Hey
I was reading the tutorial "
Insert text file
data into
Database", (awesome btw), and noticed that both a FileInputStream, a DataInputStream and a BufferedReader
how to insert data into database using jsp & retrive
how to
insert data into
database using jsp & retrive Hello,
I have created 1 html page which contain username, password & submit button. in my oracle10G
database already contain table name admin which has name, password
how to insert data in database using html+jsp
how to
insert data in
database using html+jsp anyone know what... and
database name. Here machine name id localhost and
database name... = null;
// declare a resultset that uses as a table for output
data from
unable to connect database in java
unable to connect
database in java Hello Everyone! i was trying to connect
database with my application by using java but i am
unable to connect...: [Microsoft][ODBC Driver Manager]
Data source name not fou
nd and no default driver
Insert XML file data to database
Insert XML file
data to
database
In this tutorial, you will learn how to
insert the xml file
data to
database
using dom parser.
You all are aware of XML... to read the xml file
data and save the values
of an XML file to a
Database
unable to connect database in java
unable to connect
database in java Hello Everyone! i was trying to connect
database with my application by using java but i am
unable to connect... Driver Manager]
Data source name not fou
nd and no default driver specified
Unable to store the image into database
);
}
Hi,
Please check the thread How to
Insert image into
database...
Unable to store the image into database Hello,
I have created below... = con.prepareStatement("
insert into IMAGEMAIN (id,image) values(?,?)");
pre.setString
Insert Data into Database Using Hibernate Native SQL
Insert Data into
Database Using Hibernate Native SQL... to
insert data into
database. Native SQL is handwritten SQL for all
database... native sql for inserting
data into
database.
Hibernate Native uses only
Unable to Insert Arabic words in mysql table
Unable to
Insert Arabic words in mysql table I have I java program that I want to
insert arabic letters in mysql.
Do you have any idea about the configuration of mysql that accepts arabic charcters.
in jsp use