Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JDBC how to insert date&time coloumn value in mssql
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


srikala
how to insert date&time coloumn value in mssql
2 Answer(s)      6 years and 2 months ago
Posted in : JDBC



Advertisement
View Answers

October 30, 2008 at 3:39 PM


hello,

in My sql there is a datatype "date" and "time". create a field which have date datatype in this u can store date and for time create a field which have time datatype in this u can store time.

If u want to store date and time in one field, for this u have to create a field which have varchar(25) datatype.

try this hope this will help u.


October 30, 2008 at 3:45 PM


Hi friend,

Code insert date and time in Database :

<%@ page import="java.sql.*,java.util.*,java.text.*,java.text.SimpleDateFormat" %>
<%
int val=0;
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 hh:mm:ss";
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)
{}
%>

For more information on date and time visit to :

http://www.roseindia.net/jsp/fileupload.shtml

Thanks


Related Tutorials/Questions & Answers:
how to insert date&time coloumn value in mssql - JDBC
how to insert date&time coloumn value in mssql  how to insert date&time coloumn values in mssql  hello, in My sql there is a datatype...; Hi friend, Code insert date and time in Database : <% int val=0
how to insert value in dynamic table
how to insert value in dynamic table  i am creating a project...=con.prepareStatement("insert into "+company+year+"(firstname,lastname,email... student table. and company and year value i'm getting through company table.but apache
Advertisements
how to insert checkbox value into database using jsp
how to insert checkbox value into database using jsp  how to insert check box value to the database using jsp my code is <link href..." name="pmanager" value="Enter" ></td> <td align
how to insert checkbox value into database using jsp
how to insert checkbox value into database using jsp  How to insert check box value to the oracle database using jsp? I want to create hotel's package. where the admin will select the activities to insert in the PACKAGE table. I
how to insert checkbox value into database using jsp
how to insert checkbox value into database using jsp  How to insert check box value to the oracle database using jsp? I want to create hotel's package. where the admin will select the activities to insert in the PACKAGE table. I
how to delete specified coloumn from database(MS Access) by using windows application
how to delete specified coloumn from database(MS Access) by using windows application  how to delete specified coloumn from database(MS Access) by using c# windows application
How to retrieve single row from MSSQL
How to retrieve single row from MSSQL  Hello sir, Sir i had created the table in MSSQL,the fields with patient name,pid,Dname(doctor name... created table in MSSQL,GUI in eclipse.How to achieve it.. Thanks & Regards
How to retrieve single row from MSSQL
How to retrieve single row from MSSQL  Hello sir, Sir i had created the table in MSSQL,the fields with patient name,pid,Dname(doctor name... created table in MSSQL,GUI in eclipse.How to achieve it.. Thanks & Regards
How to retrieve single row from MSSQL
How to retrieve single row from MSSQL  Hello sir, Sir i had created the table in MSSQL,the fields with patient name,pid,Dname(doctor name... created table in MSSQL,GUI in eclipse.How to achieve it.. Thanks & Regards
how to store image upload path to mssql database
how to store image upload path to mssql database  hi there!!, i need...="file" value="./books/"></td> </tr> <tr><td colspan="2...="submit" value="Send File"> </td></tr> <table> <
how to store image upload path to mssql database
how to store image upload path to mssql database  hi there!!, i need...="file" value="./books/"></td> </tr> <tr><td colspan="2...="submit" value="Send File"> </td></tr> <table> <
how to store image upload path to mssql database
how to store image upload path to mssql database  hi there!!, i need...="file" value="./books/"></td> </tr> <tr><td colspan="2...="submit" value="Send File"> </td></tr> <table> <
how to store image upload path to mssql database
how to store image upload path to mssql database  hi there!!, i need...="file" value="./books/"></td> </tr> <tr><td colspan="2...="submit" value="Send File"> </td></tr> <table> <
How to convert Mssql Procedure into Mysql Procedure.
How to convert Mssql Procedure into Mysql Procedure.  Hello Sir, I have a mssql procedure and i need it to be converted to mysql ... Below is my mssql procedure code.. WITH CTE AS ( SELECT ROW
How to convert Mssql Procedure into Mysql Procedure.
How to convert Mssql Procedure into Mysql Procedure.  Hello Sir, I have a mssql procedure and i need it to be converted to mysql ... Below is my mssql procedure code.. WITH CTE AS ( SELECT ROW
how to upload image from jsp to mssql
how to upload image from jsp to mssql  hi there!!, i'm using jsp...="2"><input type="submit" value="Send File"> </td></tr> <..."); File f = new File(saveFile); psmnt = connection.prepareStatement("insert
how to upload image from jsp to mssql
how to upload image from jsp to mssql  hi there!!, i'm using jsp... colspan="2"><input type="submit" value="Send File"> </td></tr>..."); File f = new File(saveFile); psmnt = connection.prepareStatement("insert
PHP Insert Value
Insertion of data into table: We will study in this tutorial how to insert... default value earlier, Type: insert into student values ('name', 21, 'emp_id... server, following screenshots will help you to learn how to insert into values
how insert data from databse in array and compare new data to already stored value in array
how insert data from databse in array and compare new data to already stored value in array   hello all i tried to fetch data from databse and try to stored it in an array and i want to compare new value that come from database
JComboBox Insert Edited Value Into Table
JComboBox Insert Edited Value Into Table In this section we will read about how to make JComboBox an editable and then how to insert the new edited value... in to insert an editable value of JComboBox into a table. We will use an Java editor
code for insert the value from jsp to access database
code for insert the value from jsp to access database  code for insert the value from jsp to access database
how to insert a summary values in grid
how to insert a summary values in grid  how to insert a summary value in grid
how to insert check box
how to insert check box   how to insert check box into jtable row in swing
how to insert image into server
how to insert image into server  how to insert an image into sql server and retrieve it using jSP
How to insert clob data??
How to insert clob data??  Can any one tell me in details how... pl/sql blocks and statements.I want to insert value of a textarea into clob... to insert more than 4000 characters.I have heard that clob fields can hold 4 gb
how to get radio value
how to get radio value    how to retrive the option value and insert the next table pls give example
insert excel value in to oracle data base
insert excel value in to oracle data base  Hi All I am using this code for saving excel value to oracle database table. code is working properly but in table i am geting some diffrent type value like... o
How to insert rows in jTable?
How to insert rows in jTable?  Hi, I need to take input from user using JTable. I want an empty row to appear after clicking a insert button... not figure out how to. I used DefaultTableModel but wasnt able to insert a row
insert/update records with some of the columns having NULL value.
insert/update records with some of the columns having NULL value.  How do I insert/update records with some of the columns having NULL value
how to insert one table to anothere table
how to insert one table to anothere table  i have insert the record one table then i retrve the value of that table i insert one value at a time
How to insert a car in the picture, insert a car in the picture, insert a car
How to insert a car in the picture   ... how to insert an object on the another place. Picture: Take a picture of the road and a car to insert.   Paste: Copy the car picture and paste
Advertisements
 

 

 

DMCA.com