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



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

Have Programming Question? Ask it here!
 
 
 


srikala
how to insert date&time coloumn value in mssql
2 Answer(s)      5 years and 9 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 get radio value
how to get radio value    how to retrive the option value and insert the next table pls give example
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 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 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
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
How to insert rows from Excel spreadsheet into database by browsing the excel file?
How to insert rows from Excel spreadsheet into database by browsing the excel file?  I want to insert rows from excel sheet to database.for this i... excel file and insert rows into MSSQL database in JSP???   Have a look
How to move a value in array?
How to move a value in array?   Enter value at the End: 5 Display... something wrong...pls help me fix this problem. when you insert value at the beginning... value at the End again 8 Display Array Elements Index at [0]0 Index at [1]0 Index
How to move a value in array?
How to move a value in array?   Enter value at the End: 5 Display... something wrong...pls help me fix this problem. when you insert value at the beginning... value at the End again 8 Display Array Elements Index at [0]0 Index at [1]0 Index
Insert value of dynamic generated text box in jsp using javascript
Insert value of dynamic generated text box in jsp using javascript  ... reloading the page what i want is i can insert the multiple columns value generated... javascript code given at your site now sir problem is i am not able to insert
how to update the value of jslider
how to update the value of jslider  hello, I want to make a audio player but the jslider is not updating help me
how to update the value of jslider
how to update the value of jslider  hello, I want to make a audio player but the jslider is not updating help me
how to update the value of jslider
how to update the value of jslider  hello, I want to make a audio player but the jslider is not updating help me
how to update the value of jslider
how to update the value of jslider  hello, I want to make a audio player but the jslider is not updating help me
how to update the value of jslider
how to update the value of jslider  hello, I want to make a audio player but the jslider is not updating help me
How to save value in JSP
How to save value in JSP  Employee Name Time-IN Time-OUT... 324 2012-12-12 save i want to save dis value jsp to action ...how can i get all value ..and store..how can its values goes
how to archive cllocation value
how to archive cllocation value  hi, Am working with location based application, need to store cllocation value in array, for that i need to arhive it using NSKeyarchiver... haved searche not net but didnt find anything on how
how to archive cllocation value
how to archive cllocation value  hi, Am working with location based application, need to store cllocation value in array, for that i need to arhive it using NSKeyarchiver... haved searched on net but didnt find anything on how
how to insert values from jsp into ms access
how to insert values from jsp into ms access   how to insert values using jsp into ms access database
MySQL or MSSQL - SQL
MySQL or MSSQL  How to enter data into the column of table at runtime in MySQL? Means in other words which type of command or query i will fire on the column, then it will ask value to enter at runtime? please give details
how to insert data from netbeans into databse
how to insert data from netbeans into databse  how to insert data from netbeans into databse   Please visit the following link: http://www.roseindia.net/webservices/web-services-database.shtml
How can i search and insert within a query
How can i search and insert within a query  if it is possible... that when seat numbers more then one problem generates how insert multiple values... then insert these data (batch, semester, degree, seat numbers and marks of mid, lab
how to set the value of textfield constant
how to set the value of textfield constant  how to set the value of textfield constant
how to get the checkbox value in jsp
how to get the checkbox value in jsp  how to get the checkbox value in jsp?   JSP CheckBox Example - how to get the checkbox value in jsp
how to insert the physical path of an image in database - JDBC
how to insert the physical path of an image in database  hello I m... , the image column is of varchar datatype.. plz can you tell me how to insert image's path.. and also how to retrive that image path and show that picture in a small
Advertisements
 

 

 

DMCA.com