Jagadeesh
To store date
1 Answer(s)      6 years and 11 months ago
Posted in : JSP-Servlet
Advertisement
View Answers

September 27, 2008 at 11:56 AM


Hi friend,


Code to store date in database :

<%@ page import="java.sql.*,java.util.*,java.text.*,java.text.SimpleDateFormat" %>
<html>
<%
Connection con=null;
PreparedStatement pstatement = null;
String url = "jdbc:mysql://localhost:3306/";;
String dbName = "file_upload";
String driver = "com.mysql.jdbc.Driver";
String userName = "root";
String password = "root";
try{

Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection(url+dbName,userName,password);
java.util.Date now = new java.util.Date();
String DATE_FORMAT = "yyyy-MM-dd";
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);


String strDateNew = sdf.format(now) ;




String queryString = "INSERT INTO file_tbl set file_date='"+strDateNew+"'";

//out.println(queryString);

pstatement=con.prepareStatement(queryString);


val = pstatement.executeUpdate();

if(val>0)
{
%>
<br><br>
<b><%=strDateNew%> Inserted into Database .</b>
<%
}


}
catch(Exception e)
{}
}
%>
</html>

For read more in details :
http://www.roseindia.net/jsp/fileupload.shtml

Thanks









Related Tutorials/Questions & Answers:
To store date - JSP-Servlet
the method. And send the actual query to store the date also. With lots of thankzs.....   Hi friend, Code to store date in database...To store date  Hai friends, I want the format to store
How to Store Date - Java Beginners
How to Store Date  How to Validate date in JTextField ,How I can Store it in Aceess Databse, and I want to set Last Date of Admission,if Last date of admission is equal to current date then i want display Today is Last date
Advertisements
Jsp Code to store date in database - JSP-Servlet
Jsp Code to store date in database   Hi, Can u give me jsp code to store current date in to database. Thanks Prakash
store current system date in to database - Development process
store current system date in to database  Hi,this is my code . here iwant to store current system date in to database and want to store subdept..."].elements["combo2"].options.length=0; for (var i=0;i<% java.util.Date date
store
store  i want to store data in (.dat) file format using swing and perform operation on that insertion,deletion and update
store
store  hi i want store some information in my program and use them in other method. what shoud i do
date
date  how to store in database (oracle 10 g) using JDBC and servlets... database table name birthday (DOB date); dob with DATE data type in database while...=d.getTime(); java.sql.Date date = new java.sql.Date(t); try
date
date   how to insert date in database? i need coding
date
date  i want difference between the date entered in a jtextfield and the system date in java
date
date  can u tell me how to calculate difference between a user provided date and the system date in java
date
date  can u tell me how to calculate difference between a user provided date and the system date in java
date
date  how to insert date using html through the combobox
date
date  how to insert date using html through the combobox
date
date  how to insert date using html through the combobox
date
date  how to insert date using html through the combobox
DATE
DATE  I have the following as my known parameter Effective Date... of calcultion starts My question is how to find the date of Thursday This cycle... the date of all the thursdays of the given year. import java.util.*; import
Batchwise Store
Batchwise Store  i want to read the column from excel and store the data as batchwise into database
Java Xml Data Store
phone number, nature and date of the enquiry, and the name of the salesperson... enquiries sorted by date (ascending or descending) depending if they have be followed up and/or purchased. You will need to store the data in a local binary
About Store Procedure
About Store Procedure  Create Procedure CMTSPCasesByWorkstream...((Cast(dateadd(day,-7,cast(getdate() as Date)) as varchar) + ' 23:59:59') as Datetime) -- 'yyyy-mm-dd hh:mm:ss' Declare @startdate datetime = @paramstart_date
Store ResultSt Data in a Map
Store ResultSt Data in a Map  i want to store data in a hash Map .Please solve my problem as soon as possible
How to store image into database
How to store image into database  Hi, all I want to store image into database using Java. Can anyone help me that how can i store image into database using Java. Thanks in advance.   hi friend, To store image
How to store an image in database
How to store an image in database  Hi........... How to store an image in postgresql using a query. I mean tell me the way to store an image using datatype. I am using the datatype bytea but tell me how to insert the image
iPad App to store data
iPad App to store data  Hi, How to add data support iPad application? Thanks
image store and get it back
image store and get it back  store the image in the oracle using blob... store the image in table but at time of reading it back it never shows me the image and how to convert the image file into binary format.... so that i can store
Store Variable in Java
Store Variable in Java  How to store Variables in Java?   public class DoubleTest { public static void main(String[] args) { double aDouble = 5.76; // Declare and initialize aDouble System.out.println
image store in database - JDBC
image store in database  Dear Deepak Sir, If I want to store image into the database what is the process to do that? Please explain... to store image into database. Check at http://www.roseindia.net/servlets/insert
store and retrieve data
store and retrieve data  sir,i want to store the entering data in a word file and retrieve it when i need.i am try to develop a video portal.in which user can watch video and write comments.the comments are stored in a file
dbase store - JSP-Servlet
dbase store  HI! In my project i have to store phone number in dbase. i used numeric (11,0) as data type for phone number. When i am trying to store the phone number, It is show showing error for Input String "given phone number
Android mobile store
Android mobile store  Hi, How to create Android mobile store application? Is there any free code that can be used for creating the applications? I want to distribute my application from my website. I don't what to distribute
inventory System of Medical Store
to develop a software based on Inventory System of a Medical Store. Sir, Ma'am, could... Unventory System for a Medical Store..... What I am required to know....n den implement....? Any help is greatly appreciated!!! Medical Store. Sir, Ma'am, could u
inventory System of Medical Store
to develop a software based on Inventory System of a Medical Store. Sir, Ma'am, could... Unventory System for a Medical Store..... What I am required to know....n den implement....? Any help is greatly appreciated!!! Medical Store. Sir, Ma'am, could u