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............

Comments

Popular posts from this blog

How do i Increase the capacity of the Eclipse Output console?

An internal error occurred during: "Building workspace". Java heap space

How to convert the Math Number to Words in Java?