I am trying to insert data into MySQL database where one of the column gets the current date.
The code is
unit=request.getParameter("unit");
name=request.getParameter("name");
article=request.getParameter("article");
String user=request.getParameter("username");
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/newsletter?", "root", "pooja");
Statement st = conn.createStatement();
String query="insert into browse values('"+0+"','"+name+"', '"+NOW()+"', '"+article+"', '"+unit+"', '"+user+"' );";
ResultSet rs = st.executeQuery(query);
The code throws an error at NOW() saying the method is undefined. Is there any correction I can make in this code itself or is there any other way I can enter the current date into the database?
Thanks in advance.