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
//OshwalDAO.java
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
{
try
{
Statement SQLStatement = getDatabaseConnection();
String SQLQuery = "INSERT INTO Logs (Username , LogDate) VALUES ('" + Username +"' , '" + CurrentDate+"')";
SQLStatement.execureQuery(SQLQuery);
DestroySQLConnection();
}
catch (ClassNotFoundException cnfe)
{
System.out.println(cnfe);
throw cnfe;
}
catch (SQLException SQLE)
{
System.out.println(SQLE);
throw SQLE;
}
Now the servlet does the action calls the method.
LoginServlet.java
OshwalDAO Dao = DAO.getDAOInterface();
java.util.Date CurrentDate = new Date();
Dao.InsertLog(request.getparameter("Username") , CurrentDate);
response.sendRedirect("DateSuccessful.jsp");
This is the Code. The Error i get is syntax error in the SQL Statement.
All Help Appreciated.
Thank You!