Hello Everyone! Very close to completing my project but a small favor needed! Which is blocking me from finishing the last section of the project!

This is how it goes!!!!!

Have an Interface with inc complete methods


void InsertLog(String LogID , String Username , java.Util.Date CurrentDate)
throws ClassNotFoundException , SQLException;

Have a DAO File which contains all code to perform database actions:

//DAO.java implements OshwalDAO.java

public void InsertLog (String LogID , String Username , java.util.Date CurrentDate)
      throws ClassNotFoundException , SQLException


            Statement SQLStatement = getDatabaseConnection();
            String SQLQuery = "INSERT INTO Logs (Username , LogDate) VALUES ('" + Username +"' , '" + CurrentDate+"')";


     catch (ClassNotFoundException cnfe)
            throw cnfe;

     catch (SQLException SQLE)
            throw SQLE;

Now the servlet does the action calls the method.


OshwalDAO Dao = DAO.getDAOInterface();

java.util.Date CurrentDate = new Date();

Dao.InsertLog(request.getparameter("Username") , CurrentDate);


This is the Code. The Error i get is syntax error in the SQL Statement.

All Help Appreciated.

Thank You!

1) I do wonder if you did direct copy or paste since your interface Date class is wrong java.Util.Date
2) You should have used java.sql.Date 3) I received up-vote from you for MVC tutorial, so I would have expected from you to use PreparedStatement instead of single & double quote hell
4) If you get exception it is always best to post exact error

commented: Thanks Friend for the useful post! :-) +3

Hey peter thanks! Gt the answer! used


thanks for the assistance. Sorry for the error did not do direct copy was writing the exact code from my program! So sorry for the grammatical errors since java is case sensitive.

I used the java.sql.Date and it worked! Want to thank u alot! Cheerz!

Yes i had upvoted for the MVC Tutorial! You Saved me with that tutorial! Its nice once again to learn from outstanding tutorials from you! Thank u for posting it!

:-) :-) :-) :-)