

Hello i tried the above insert code bt am getting the following error com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'sysdate(date)value('2012-04-01 05:45:43')' at line 1
bt when inserted the same query in mysql its working fine.
plzz tell me how to resolve it.
herz my code:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
// TODO Auto-generated method stub
try
{
System.out.println("Hello");
Class.forName("com.mysql.jdbc.Driver");
Connection connection= DriverManager.getConnection("jdbc:mysql://localhost/test","root","sayali");
PreparedStatement pst = null;
java.util.Date now = new java.util.Date();
String DATE_FORMAT = "yyyy-MM-dd hh:mm:ss";
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
String current_date_time = sdf.format(now) ;
String query = "INSERT INTO sysdate(date)value(?)";
pst = connection.prepareStatement(query);
pst.setString(1,current_date_time);
System.out.println(pst);
//out.println(queryString);
int UpdateQuery = pst.executeUpdate();
System.out.println(UpdateQuery);
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("error");
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.