How can we print the current date in the Mysql Database?
Most formally we use the now(); method...
For Now() method it display the current date.
If use now method directly in
pst = con.prepareStatement
("insert into uploadfilename values('" + uf.id + "','" + myFileFilename + "','" + now() + "')");
int x = pst.executeUpdate();
I used this and execute it in the local database. It is updated in the database. but while executing in the live server it will through two exceptions
InvocationTargetException and NoClassDefFoundError Exception.
It will execute the current date in the database but it shows some warnings.. but it is not the correct way to display the date
Date d = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
String df = sdf.format(d);
con = getconnection();
pst = con.prepareStatement
("insert into uploadfilename values('" + uf.id + "','" + myFileFilename + "','" + df + "')");
int x = pst.executeUpdate();
After that i execute this code. Then it will run correctly in the live server............
For Now() method it display the current date.
If use now method directly in
pst = con.prepareStatement
("insert into uploadfilename values('" + uf.id + "','" + myFileFilename + "','" + now() + "')");
int x = pst.executeUpdate();
I used this and execute it in the local database. It is updated in the database. but while executing in the live server it will through two exceptions
InvocationTargetException and NoClassDefFoundError Exception.
It will execute the current date in the database but it shows some warnings.. but it is not the correct way to display the date
Date d = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
String df = sdf.format(d);
con = getconnection();
pst = con.prepareStatement
("insert into uploadfilename values('" + uf.id + "','" + myFileFilename + "','" + df + "')");
int x = pst.executeUpdate();
After that i execute this code. Then it will run correctly in the live server............
Comments
Post a Comment