I am trying to insert date in database, I have primary key EVENTID with data type Date:
This part of my class where i am performing this function
package DBAccess;
import DBAccess.*;
import java.io.* ;
import java.util.*;
import java.sql.*;
import javax.sql.*;
import javax.naming.*;
Date today = new Date();
This is my function
public void createEvent(
String Attendees,String Notes, String Check)
{
try
{
Context context = new InitialContext();
DataSource ds = (DataSource) context.lookup( "itarchutil-datasource" );
Connection con = ds.getConnection();
Statement stmt = con.createStatement();
stmt.executeUpdate ("Insert into sandbox.event(EVENTID,OTHERATTENDEE,NOTES,APPROVE)values('" + today + "','" + Attendees + "','" + Notes + "','" + Check + "')");
stmt.close();
con.close();
}
catch (Exception e)
{
System.out.println("Error:" + e);
}
}
I am getting the following errors:
H:\itads\source\DBAccess\ProjectDatabase.java:11: 'class' or 'interface' expected
[javac] today = new Date();
H:\itads\source\DBAccess\ProjectDatabase.java:298: cannot resolve symbol
[javac] symbol : variable today
[javac] location: class DBAccess.ProjectDatabase
[javac] stmt.executeUpdate ("Insert into sandbox.event(EVENTID,OTHERATTENDEE,NOTES,APPROVE)values('" + today + "','" + Attendees + "','" + Notes + "','" + Check + "')");
Can any one help??
Thanks
^