Share on Google+Share on Google+

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

Ads

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
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
Tutorials   
Java Spring Hibernate Struts Training how to retrieve text and images from mysql database and show on html page using jsp servlet How to install Neo4j on Ubuntu 15.10? please help me in these prog MYSQL - mysql copy table to another table example by creating new table solution for mapping hibernate and pojos from net beans through database Connect GWT application with Oracle inventory System of Medical Store inventory System of Medical Store inventory System of Medical Store inventory System of Medical Store This code have created jTable that connected with a database.every cell of last column have a button.But this button doesn't work properly.Where is the error java program Java Database Program jdbc Database connection class in a live project ..?? What is JDBC architecture? Unable to Create DSN for excel to ms access importing data and edit that data Database Scrolling Buttons how to use foreign key in java How to delete content of a log file from linux terminal? JSP-Oracle connectivity Student Management System Java code for Saving Marathi (Indian local language ) in Mysql and retrieving the same crud operations with foreign key constraint. I really need help with this assignment question Please help me out Please Backup Failed Mysqldump Got Errno 28 On Write Upgrade MySQL 5.1 to 5.5 in cpanel mysqldump all databases com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'jpa.sequence' doesn't exist persistence xml class element persistence.xml for MySQL MySQL JDBC Driver pom dependency code Blob column jdk6 and oracle 8i connexion oracle 8i et jdk6 java [ cannot retrive date from sql ] why?? Order Entry System How to threow timeout exception when DB is not responding How to threow timeout exception when DB is not responding This is the employee form to add data to mysql database but I got error of NullPointerException, Is this write code please give me feedback as soon as possible make a method which takes user name & pwd as parameter & validate them against the database. If the corresponding user exist return true otherwise false. prabhakar validating credentials and displaying error message in login .jsp if not valid JDBC jdbc jdbc code register servlet vibhu connectiondetails from vibhu

Ads

 
Advertisement null

Ads