How to insert date/time to sql database
Hi,
I would like to insert date and time alongside with my data receiving from the sensor.
Right now i can insert data into sql table everytime when the data changes but i also wanted to insert the date and time as well.
Thank you in advance!
I create a field that is a datetime and set the default value to getdate(). So everytime i make an entry into this database, it automatically adds a datestamp.
Similar Messages
-
*Urgent*How to insert data from MS SQL to the table that create at the adobe form?
Hi,
I'm using Adobe life cycle designer 8 to do my interactive form. I would like to ask how to insert data from MS SQL to the table that i have created in my adobe interactive form?
I really need the information ASAP as i need to hand in my project by next week... i really appreciate any one who reply this post.
ThanksTou need to do a couple of things
1. On the Essbase server, set up an odbc system connection to your MySQL database
2. In the load rule , go to the file menu and select open SQL data source and in the data source put in your SQL statement . A couple of hints. Where it says Select, don't put in the word select and where it say from don't put in from. The system adds them for you. The easiest way ti enter a SQL statement is to do it all in the select area So if your SQL would normanlly say select * from mytable just enter the code as * from mytable in the select area
The click ol/retrieve and enter in your connection info. Itshould bring data back into the load rule. Save the load rule and use it -
How to insert date into ms access database using sql query in servlet
sir all thing is working well now only tell me how we can insert date into ms access database which is input by user .
insert into db2(bookname,studentname,date) values('"+bname+"','"+sname+"',date_format)";{code}
or either the system date is inserted with query .
plz help me
thanxbhavishya wrote:
sir all thing is working well now only tell me how we can insert date into ms access database which is input by user .
insert into db2(bookname,studentname,date) values('"+bname+"','"+sname+"',date_format)";{code}
or either the system date is inserted with query .
plz help me
thanxAnd that SQL statement is another reason to use PreparedStatement. I assume bname and sname are input from some form? Well, if that's the case, simply inserting them into SQL by simple String concatenation is just begging for all sorts of problems. What if there is an apostrophe in the entry? Broken Statement. Worse, it's a wide open invitation to an SQL Injection attack. -
Insert date time into oracle database from jsp
pls tell me ,from jsp how can I insert datetime values into oracle database .I am using oracle 9i .here is codethat i have tried
html--code
<select name="date">
<option selected>dd</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
<select name="month">
<option selected>dd</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
<select name="year">
<option selected>dd</option>
<option>2004</option>
<option>2005</option>
<option>2006</option>
<option>2007</option>
</select>
here the jsp code
<% date= request.getParameter("date"); %>
<% month= request.getParameter("month"); %>
<% year= request.getParameter("year"); %>
try
{ Class.forName("oracle.jdbc.driver.OracleDriver"); }
catch (ClassNotFoundException exception)
try
Connection connection = null;
out.println("connectiong the database");
connection = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:orcsid","scott","tiger");
out.println("connection getted");
int rows = 0;
String query_2 = "insert into mrdetails values(?)";
String dob = date+month+year;
prepstat = connection.prepareStatement(query_2);
prepstat.setTimestamp(4,dob);
rows = prepstat.executeUpdate();
out.println("data updated");
catch (Exception exception3)
out.println("Exception raised"+exception3.toString());
}To insert date values into a database, you should use java.sql.Date. If it also has a time component, then java.sql.TimeStamp.
Your use of prepared statements is good.
You just need to convert the parameters into a date.
One way to do this is using java.text.SimpleDateFormat.
int rows = 0;
String query_2 = "insert into mrdetails values(?)";
String dob = date+"/" + month+ "/" + year;
SimpleDateFormat sdf = new SImpleDateFormat("dd/MM/yyyy");
java.util.Date javaDate = sdf.parse(dob);
java.sql.Date sqlDate = new java.sql.Date(javaDate .getTime);
prepstat = connection.prepareStatement(query_2);
prepstat.setTimestamp(4,sqlDate);
rows = prepstat.executeUpdate();
out.println("data updated");Cheers,
evnafets -
Problem while inserting Date/Time in Oracle Database
Hai,
i want to insert the date and time in a date column. here, i am using java.sql.Date and java.sql.Time to assign the date in Prepared Statement.
PreparedStatement psmt=con.prepareStatement("insert into test(ex_date) values(?)");
java.util.Calendar c=Calendar.getInstance();
c.set(2002,2,21,10,10,00);
java.sql.Date d=new Date(c.getTime().getTime());
java.sql.Time t=new Time(c.getTime().getTime());
psmt.clearParameters();
psmt.setDate(1,d);
psmt.setDate(1,t);
psmt.executeUpdate();
Above program is inserted the Date and time in the database as the following "1900/2/21 10:10 AM"
but i am giving the year as 2002. it inserted the year as 1900. what is the problem with the code?
please let me know
Thanks in advance.
Regards
sankarjune14Hai Franco,
i put the wrong code. Here, is the Original Code.
PreparedStatement psmt=con.prepareStatement("insert into test(ex_date) values(?)");
java.util.Calendar c=Calendar.getInstance();
c.set(2002,2,21,10,10,00);
java.sql.Date d=new Date(c.getTime().getTime());
java.sql.Time t=new Time(c.getTime().getTime());
psmt.clearParameters();
psmt.setDate(1,d);
psmt.setTime(1,t); // Last time i put psmt.setDate(1,t);
psmt.executeUpdate();
and, the getTimeInMillis() method is a protected method in java.util.Calendar class. how can we use it
please give me some other idea to insert the date and time in oracle database.
Thanks in advance
sankarjune14 -
How To Insert Data into a Access Database from a PDF File
Hi All,
Could anyone help me to insert PDF form data to an MS Access database.I am new to this and I would appreciate if anyone can help me at the earliest.
Thanks,
DeeptiYou can submit your PDF to a server-side script (ASP/PHP), and store the new record in a MS Access database.
For more information on how to store your PDF submission in a database, please visit:
http://www.fdftoolkit.net -
How to insert data from screen to database Table..??
This is regarding screen painter area..
I have created a Z-table.
Also created a screen where i am having input box.
After entering text in the input box, i will click "SAVE" push button.
When i click "SAVE" push button, the Text entered in the screen input box should be saved in that z-table.
How to do it...??
Can anybody explain me with ABAP code...???
Thanks
PavanHi,
You can try follwong logic.
tables : ztable.
data wa_ztable like line of ztable.
Case sy-ucomm.
when 'SAVE'.
clear wa_ztable.
wa_ztable-field1 = screenfield1.
wa_ztable-field2 = screenfield2.
wa_ztable-field3 = screenfield3.
modify ztable from wa_ztable.
endcase.
If it is simple database insertion,
you can always use Table Maintainance provided by SAP.
So that the code will be automatically generated and you dont have to worry.
Regards,
Shashank -
How to insert data quickly to sqlite database
I have a XML file where the data is written and I want to add it to a database the file has 180000 entries.and takes one day in save that data I want do it quick, there are another way to do it, I'm using the foreach statement to parse and add to the
database. And i wonder if one background task will solve the performance of the form, also want add a dialog what's says the line what is recorded and add a stop or pause button for continue late if there's no way to do it quickly
ThanksI have a XML file where the data is written and I want to add it to a database the file has 180000 entries.and takes one day in save that data I want do it quick, there are another way to do it, I'm using the foreach statement to parse and add to the
database. And i wonder if one background task will solve the performance of the form, also want add a dialog what's says the line what is recorded and add a stop or pause button for continue late if there's no way to do it quickly
Thanks
Hello,
>>I have a XML file where the data is written and I want to add it to a database the file has 180000 entries.and takes one day in save that data I want do it quick,
In this case, the main issue is to deal with large XML file, you could consider using
XmlReader as the following thread suggested.
C# and Reading Large XML Files
In addition, you could consider using LINQ to XML, and we could split that large xml file with the following way.
Easy Method to Split Large XML File Using LINQ to XML.
Regards,
Carl
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
How to insert data type information to oracle database
Hi, there,
I want to insert date information to oracle database in a jsp page using JSTL. but always got wrong message:
javax.servlet.jsp.JspException:
INSERT INTO DATE_TEST
(date_default,date_short,date_medium)
values(?,?,?)
: Invalid column type
I don't know how to convert java date type to oracle date type or vice versa. the following is the source code(all the fields of DATE_DEFAULT,DATE_SHORT,DATE_MEDIUM are oracle date type. and even I want to insert d instead d1, I got the same wrong message)
<%@ page contentType="text/html;charset=windows-1252"%>
<%@ page import="java.util.*" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
<%
Calendar now;
Calendar rightNow = Calendar.getInstance();
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>
Hello World
</title>
</head>
<body>
<h2>
The current time is:
</h2>
<p>
<%= new java.util.Date() %></p>
<%
java.util.Date d=new java.util.Date();
java.sql.Date d1=new java.sql.Date(d.getYear(),d.getMonth(),d.getDate());
out.print(d1.toString());
%>
<sql:update>
INSERT INTO DATE_TEST
(DATE_DEFAULT,DATE_SHORT,DATE_MEDIUM)
VALUES(?,?,?)
<sql:dateParam value="${d}" type="date" />
<sql:dateParam value="${d}" type="date" />
<sql:dateParam value="${d}" type="date" />
</sql:update>
</body>
</html>
thank you very much for the great help!!I don't have time to read thru all your code, but I hope this information will help you.
It depends on how the Oracle database was set up. Usually, the date format is something like this: '27-MAY-2003 22:10:00'. A quick check will be to run this SQL script in SQLPlus:
select sysdate from dual;
You have to convert the date from textbox or whatever to this exact Oracle format. Otherwise, Oracle will not accept it. It is very picky on that. I found the best way is to do the conversion inside the SQL statement. It makes life so much easier.
Hope this helps. -
How to insert date into oracle database
Hi, there,
I want to insert date information to oracle database in a jsp page using JSTL. but always got wrong message:
javax.servlet.jsp.JspException:
INSERT INTO DATE_TEST
(date_default,date_short,date_medium)
values(?,?,?)
: Invalid column type
I don't know how to convert java date type to oracle date type or vice versa. the following is the source code(all the fields of DATE_DEFAULT,DATE_SHORT,DATE_MEDIUM are oracle date type. and even I want to insert d instead d1, I got the same wrong message)
<%@ page contentType="text/html;charset=windows-1252"%>
<%@ page import="java.util.*" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
<%
Calendar now;
Calendar rightNow = Calendar.getInstance();
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>
Hello World
</title>
</head>
<body>
<h2>
The current time is:
</h2>
<p>
<%= new java.util.Date() %></p>
<%
java.util.Date d=new java.util.Date();
java.sql.Date d1=new java.sql.Date(d.getYear(),d.getMonth(),d.getDate());
out.print(d1.toString());
%>
<sql:update>
INSERT INTO DATE_TEST
(DATE_DEFAULT,DATE_SHORT,DATE_MEDIUM)
VALUES(?,?,?)
<sql:dateParam value="${d}" type="date" />
<sql:dateParam value="${d}" type="date" />
<sql:dateParam value="${d}" type="date" />
</sql:update>
</body>
</html>
thank you very much for the great help!!Hi, there,
I want to insert date information to oracle database in a jsp page using JSTL. but always got wrong message:
javax.servlet.jsp.JspException:
INSERT INTO DATE_TEST
(date_default,date_short,date_medium)
values(?,?,?)
: Invalid column type
I don't know how to convert java date type to oracle date type or vice versa. the following is the source code(all the fields of DATE_DEFAULT,DATE_SHORT,DATE_MEDIUM are oracle date type. and even I want to insert d instead d1, I got the same wrong message)
<%@ page contentType="text/html;charset=windows-1252"%>
<%@ page import="java.util.*" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
<%
Calendar now;
Calendar rightNow = Calendar.getInstance();
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>
Hello World
</title>
</head>
<body>
<h2>
The current time is:
</h2>
<p>
<%= new java.util.Date() %></p>
<%
java.util.Date d=new java.util.Date();
java.sql.Date d1=new java.sql.Date(d.getYear(),d.getMonth(),d.getDate());
out.print(d1.toString());
%>
<sql:update>
INSERT INTO DATE_TEST
(DATE_DEFAULT,DATE_SHORT,DATE_MEDIUM)
VALUES(?,?,?)
<sql:dateParam value="${d}" type="date" />
<sql:dateParam value="${d}" type="date" />
<sql:dateParam value="${d}" type="date" />
</sql:update>
</body>
</html>
thank you very much for the great help!! -
How to insert data from *.dmp file to oracle 11g using Oracle SQL Develope
hi
i backup my database using PL/SQL developer and made *.dmp file
how to insert data from *.dmp file to oracle 11g using Oracle SQL Developer 2.1.1.64
and how to make *.dmp file from sql*plus ?
thanks in advancePl/Sql developer has a config window, there you choose the exec to do the import/export.
Find it and his home version, it may be exp or expdp, the home version is the version of the client where the exp executable is.
Then use the same version of imp or impdp to execute the import, you do not need to use Oracle SQL Developer 2.1.1.64. If you want to use it, you must have the same version in the oracle home that exp/imp of sql developer use. -
How can I Insert data into my msaccess Database table
Hello all,
I am new to Java programming and I have problem that how can i insert name into my database table.
The code which i have written is following:
String filename = "d:/test.mdb";
String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=";
database+= filename.trim() + ";DriverID=22;READONLY=true}";
Connection con = DriverManager.getConnection(database,"","");
String s = String.valueOf(text.getText());
int k =10;
Statement st = con.createStatement();
st.execute("create table Test123(name text)");
st.execute("INSERT INTO Test123 values" +s);
on the INSERT program throws exception???
can any one help me how to insert data into tabel.
Thankshe INSERT program throws exception???
can any one help me how to insert data into tabel.I have never used the jdbc driver to access, but what do you think that the flag READONLY=true means? An insert is not a read.
Kaj -
How to identify date & time of insertion of rows in a table
Hi,
Is it possible to identify the date & time of insertion of rows in a table?
for example:
Table name: emp
I have rows like this
emp_code name dept
pr01 ram edp
ac05 gowri civil
pr02 sam pro
i want to know the date and time of the insertion this( ac05 gowri civil).
Could you please help me.....
Thanks in advance....psram wrote:
sorry for the confusion. I dont want to store date and time. I said that for example only.
I have table which consists of thousands of rows. I want to know the insertion date & time of a particular row.
Is it possible?So, if I have a table that stores a load of employee numbers, do you think I could get the database to tell me their names?
If you don't store the information, you can't query the information.
Ok, there are some dribbs and drabbs of information available from the back end of the database via the SCN's, Archive Logs etc., but those sort of things disappear or get overwritten as time goes by. The only way to know the information it to ensure you store it in the first place.
So, in answer to your question, No, there isn't a true and reliable way to get the data/time that rows were inserted into the table, unless you have chosen to store it alongside the data. -
Its very urgent:how to insert data into database tables
Hi All,
I am very new to oaf.
I have one requirement data insert into database tables.
here createPG having data that data insert into one custom table.
but i dont know how to insert data into database tables.
i wrote the code in am,co as follows.
in am i wrote the code:
public void NewoperationManagerLogic()
ManagerCustomTableVOImpl vo1=getManagerCustomTableVO1();
OADBTransaction oadbt=getOADBTransaction();
if(!vo1.isPreparedForExecution())
vo1.executeQuery();
Row row=vo1.createRow();
vo1.insertRow(row);
in createPG processrequest co:
public void processRequest(OAPageContext pageContext, OAWebBean webBean)
super.processRequest(pageContext, webBean);
ManagerInformationAMImpl am=(ManagerInformationAMImpl)pageContext.getApplicationModule(webBean);
am.NewoperationManagerLogic();
process form request:
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
super.processFormRequest(pageContext, webBean);
if(pageContext.getParameter("Submit")!=null)
ManagerInformationAMImpl am=(ManagerInformationAMImpl)pageContext.getApplicationModule(webBean);
am.getOADBTransaction().commit();
please help with an example(sample code).
its very urgent.
thanks in advance
Seshu
Edited by: its urgent on Dec 25, 2011 9:31 PMHi ,
1.)You must have to create a EO based on custom table and then VO based on this EO eventually to save the values in DB
2.) the row.setNewRowState(Row.STATUS_INITIALIZED); is used to set the the status of row as inialized ,this is must required.
3.) When u will create the VO based on EO the viewattributes will be created in VO which will be assigned to the fields to take care the db handling .
You must go thtough the lab excercise shipped with you Jdeveloper ,there is a example of Create Employee page ,that will solve your number of doubts.
Thanks
Pratap -
How to insert data from access to sql server ?
How to insert data from access to sql server ?
Please help me
thanksphamtrungkien wrote:
How to insert data from access to sql server by JAVA?The first four words of my last post:
masijade wrote:
JDBC with two connectionsGet a resultset from the jdbc-odbc bridge access connection, cycle through it and add batch insert commands to the jdbc connection to sql server. Give it a try and if the code has an error, then post your code ans ask a question.
The real question, though, is why you think it absolutely necessary to use Java for this.
Maybe you are looking for
-
How do I install required plug-in jre-1_5_0_11-windows-i586.xpi
I'm trying to use Mozilla Firefox 3.6.15 with the Web Version of QPASA 4.0.0.80a, an MQSeries monitoring tool. When I point to the QPASA URL, I'm prompted to install a plugin. However, when I try to install it, Firefox looks for http://javadl-esd.sun
-
i tried downloading Final Cut ProX but my computer said that "this computer cant download Final Cut ProX" and i dont know why?
-
Problem in PO condition update
Hi Experts, I am using 'IDOC_INPUT_PORDCR1' to post PO. Everything is working fine except the repricing. ex:- In me21 if we have 'UPDATE' button at condition item level. when I am creating i need to press UPDATE button select pricing type 'C'
-
I have a 27" iMac (last year's) core i7, with minidisplayport, and an aluminum Macbook (the 2ghz one) with minidisplayport. I've hooked them together, and my iMac will take the Macbook's signal, but I don't know how to get the Macbook to serve as a
-
Where can I find the xsd file for SQL2012 .dtsx files?
Where can I find the xsd file for SQL2012 .dtsx files? Tom G.