Do you know how to run queries with java and how in general to insert data in a database?
There are several ways so can you post the code that use to insert normal data, so we can give you a suggestion similar to your code style?
Do you use PreparedStatements or jua Statements to create your query?
That parse method is giving you a java.util.Date object, you need a java.sql.Date object in the setDate method. See the Date(long) constructor of java.sql.Date and the getTime() method of java.util.Date and use the latter as the argument in the former to get a java.sql.Date instance.
Edit: P.S. it would have helped to know the exception you were getting.
Edit Again: It is also not normal to surround the schema, table, and column names with single quotes ( ' ), although you might surround them with double quotes ( " ) if they also represent reserved words in the db.
<%@ page language="JAVA" contentType="text/html" %>//directive to specify that language used is java and specifying the content type
<%@ page import="java.sql.*" %>//to import sql package
String driverClass ="com.mysql.jdbc.Driver";
String connectionString="jdbc:mysql://localhost:3306/login" ;
String query="INSERT into table_name values(?)" ;
Class.forName(driverClass) ;//to use jdbc driver to connect to mysql database
con=DriverManager.getConnection(connectionString,username,password);//to make connection
java.util.Date today = new java.util.Date();//date object
stmt.setDate(1, today.getTime());//to insert the date at the wildcard sql statement used above
int a=stmt.executeUpdate() ;//executeUpdate will return the number of affected rows
out.println("Data successfully inserted") ;
Do not use scriptlets. Scriptlets were included in the first version of JSP and quickly gotten rid of in the second. They only still exist to facilitate backwards compatability. You need to use beans, or at the very least JSTL sql tags. And JSPs should not being doing anything except displaying data, anyway. Any site request that is to actually do anything should be going to a servlet (and that should also make use of existing beans) and then, after the work is done, should be forwarding the request to a JSP to actually display the page.
while u are picking the date using date class and populating it to the database fields u might not able to store the value,if the field type in database is of type date,and u r parsing a long value ie:while ur picking it from date it is going to return the date inthe form of long value so how it is actually mapped if we use different data types for dates with respect to different databases....I think it make sence if u found any solutions plese remind here....TQ.