How to insert the system date  using PreparedStatement

How do I insert system date(from Orcale database) using
PreparedStatement. I am aware that that oracle has date
function 'sysdate' to retrieve the database current date.
How Do i use that in the following syntax?
Alertnative 1:
String inssql =
"insert into emp (empid, name, dept, updateDate) "+
" values (?, ?, ?, ?)";
PreparedStatement pstmt = conn.prepareStatement(inssql);
pstmt.setInt(1, 123456);
pstmt.setString(2, "Bougnon Kipre");
pstmt.setString(3, "Rare Species Depatement" );
pstmt.setDate(4, sysdate) // if this okay
pstmt.executeUpdate();
Alternative 2:
String inssql =
"insert into emp (empid, name, dept, updateDate) "+
" values (?, ?, ?, sysdate)";
PreparedStatement pstmt = conn.prepareStatement(inssql);
pstmt.setInt(1, 123456);
pstmt.setString(2, "Bougnon Kipre");
pstmt.setString(3, "Rare Species Depatement" );
pstmt.executeUpdate();

Hi,
The second alternative will be the best way.
Since the alternative 1 won't work. sysdate cannot be accessed
from java as a variable. Either use alternative two or create a
java.sql.Date and insert it.
Regards
Elango

Similar Messages

  • How to Insert the System Date in the entity object

    Hello,
    I have the problem - in entity object I have one attribute as 'Created_Date' in the <entity>Impl.java,
    to this attribute I want to assign the value as a System Date. Could someone please let me know how to do this?
    Thanks

    Hint for all who are trying another solution. You might think it's easier to assign a SystemDate using this method:row.setDate(new Timestamp(System.currentTimeMillis())); But unfortunately this solution has a real gotcha! Doing this you are writing an Attribute with a precision of milliseconds. Unfortunately the SQL-Date type can hold only full seconds. So this solution sometimes leads to the Problem that BC4J complains that "someon else has changed the row" (in reality the database has simply stripped off the seconds).
    Even if you are trying to convert the Timestamp to an oracle.jbo.domain.Date like this Date myDate = new Timestamp(System.currentTimeMillis()));
    row.setDate(myDate); you will not be able to solve the problem. 'myDate' still holds the milliseconds, it only doesn't display them. You might still discover that BC4J complains for modified rows.
    So the solution given by Faraz is definitively the best solution, even if it looks complicated, as it strips off the milliseconds.

  • How to remove the system data details from the overview tab in crmd_order?

    Hi All,
    How to remove the system data details from the overview tab in crmd_order?

    Hi,
    It is a standard functionality. Those information will be very useful when you send a message to SAP.
    If you still want to remove them, raise an OSS message.
    Regards,
    Rajesh Kumar

  • How to get the context data using java script in interactive forms

    Hi All,
    How to get the context data using java script in interactive forms by adobe,  am using web dynpro java
    thanks.

    Hi venkat,
    Please Refer this link.
      Populating one Drop-Down list from the selection of another Drop-down list
    Thanks,
    Raju.

  • Can we change the system date using Sql

    can we change the system date using Sql statement..
    can anyone help
    Tariq.

    There is an initialization parameter called FIXED_DATE which lets you set a fixed sysdate for testing purposes, and you can alter that date using the ALTER SYSTEM command, but as implied by the name you are setting a data/time that doesn't change. Since the normal sysdate is derived from the O/S it cannot be altered through SQL

  • How to get the system date format string?

    Hello, everybody!
    I want to create a MaskFormatter with a mask for dates. So, I could suply as the constructor parameter: "##/##/####'. However, what if the year comes first in the current system date format settings, or the month is in the second place or in the first?... So, I can't just suppose that the current locale format for dates is like the one above. So, my question is: is there a way to get the SYSTEM DATE FORMAT STRING in Java? Searching in google I saw that this was already asked in this forum:
    http://forum.java.sun.com/thread.jspa?threadID=301034&messageID=1193794
    but there was no effective answer. Does someone already know how to get this?
    Thank you.
    Marcos

    Hi, not sure, but
    import java.text.*;
    SimpleDateFormat sdf = new SimpleDateFormat();
    System.out.println(sdf.toPattern());
    will output something like dd/MM/yy HH:mm
    hthThank you very much. It worked.

  • How to get the system date as a session attribute?

    Hi all,
    How can i get the system time and date to a session?
    This is my code:
    String startDate=<How will i get (system date) here?>;
    session.setAttribute("startDate",startDate);
    String startTime=<How will i get (system time + 1hr) here?>;
    session.setAttribute("startTime",startTime);
    Thanks in advance,
    Lakshma

    This is one way:
            Calendar cal = Calendar.getInstance();
            SimpleDateFormat sd1 = new SimpleDateFormat("yyyyMMdd");
            System.out.println(sd1.format(cal.getTime()));
            SimpleDateFormat sd2 = new SimpleDateFormat("hh:mm:ss");
            cal.add(Calendar.HOUR, 1);
            System.out.println(sd2.format(cal.getTime()));

  • How to get the system date and time using java

    hi,
    I want system date in my out put. how to access system date. can v use utill packaegs (or) sql. which one is the best to get.
    Thanks & Regards,
    Kenny.

    import java.util.Date;
    import java.util.Calendar;
    import java.util.GregorianCalendar;
    public class MyClass {
    public void setTimeStamp() {
    int hour, minute, second, time = 0;
    Date dt=new Date();
    System.out.println(dt.getDate());
    System.out.println(dt.getMonth());
    System.out.println(dt.getYear());
    Calendar cal = new GregorianCalendar();
    hour = cal.get(Calendar.HOUR_OF_DAY);
    minute = cal.get(Calendar.MINUTE);
    second = + cal.get(Calendar.SECOND);
    System.out.println (hour + ":" + minute + ":" + second);
    public static void main (String args[]){
    MyClass app = new MyClass();
    app.setTimeStamp();
    }

  • How to insert the Formatted date value and insert into the database

    Hi All,
    I am having requirement of inserting the date value in to the datbase. I'm already getting the value from file as MM-DD-YYYY. Getting exception while transforming the values through the transform activity. I'm using format fate function but it is inserting null value in to the database.
    Any help from anyone would bve appreciated.
    Thanks,
    CH

    Hi,
    your input date format is fixed right? So, in the transform you can split each your date, which is in 'MM-DD-YYYY' format ... extract day, month, year.
    After that ... just put these values in order acording to the format of 'xsd:date' data type which is '[-]CCYY-MM-DDZ'.
    XPath function 'xp20:format-dateTime()' works only with 'xsd:dateTime' data type, which has format '[-]CCYY-MM-DDThh:mm:ssZ'.
    So, in your case it could be:
    <xsl:variable name="day" select="substring($inputDate,4,2)"/>
    <xsl:variable name="month" select="substring($inputDate,1,2)"/>
    <xsl:variable name="day" select="substring($inputDate,7,4)"/>
    <xsl:variable name="outputDate">
    <xsl:value-of select="$year"/>
    <xsl:text>-</xsl:text>
    <xsl:value-of select="$month"/>
    <xsl:text>-</xsl:text>
    <xsl:value-of select="$day"/>
    </xsl:variable>
    Regards,
    Martin.

  • How to get the current date using HTMLB JSP page

    Hi All, I developed an iview with several fields using PDK, I would like to know how can I include for a date field a dynamic value witch in this case is the current date.
    <hbj:inputField
    id="Date"
    type="date"
    maxlength="10"
    showHelp="TRUE"
    required="TRUE"
    value="???"
    />
    Thanks in advance
    Alexis

    Hi Alexis ,
    u can use the setDate("3.12.2003") function to set date for this input field.
    u just change the id = Date , because in jave we have Date class. rename it to another name..
    suppose id = systemDate
    <%
    Format formater = new SimpleDateFormat("dd.MM.yyyy");
    Date syDatum = new Date();
    %>
    then
    put
        systemDate.setDate(formater.format(syDatum));
    this will set the date .....
                        Regards
                        Kishor Gopinathan

  • How to update the Weekly data using BAPI for MD61

    Hi All,
    i have used two BAPI's in my Z program to upload data from flat file to sap-system (BAPI_REQUIREMENTS_GETDETAIL and BAPI_REQUIREMENTS_CHANGE) and i uploaded the Monthly Data from the flat file on sap system successfully.
    but i have to also upload the Weekly Data on the sap system using BAPI.
    is there any BAPI for the same or what can be the solution for the uploading weekly data on sap system ?
    Please reply me.
    Thanks in advance..
    Edited by: Prajapati_Shyam on Dec 29, 2010 4:19 PM

    Hi Jovito,
    thanks for your reply,
    i developed a Z program to upload monthly data as well as weekly data into tcode MD61 by selecting the radio button weekly or monthly but i am not able to upload the weekly data as i didnt' get any BAPI OR any other logic to upload weekly data Or not able to use the existing BAPI BAPI_Requirement_create , because the upload file is in monthly format.
    MD61 tcode can be used for both data (Monthly or weekly data).
    can you suggesst me any BAPI to upload the weekly data or any other logic for the same
    thanks & regards
    Prajapati

  • How to know the system configuration using Java.

    Hello Everyone,
    I wanna know the system configuration (Hard Disk size,Ram capacity,Processor speed) .Can we know it using Java API? Or else is there any API which makes my life easier?
    Can someone let me know,please?
    All ur answers r most welcome.
    Thanks

    --> provides you with some basic info on os user and os but my best bet is to find a windows system file that maintains this information and then read the data from it
    import com.sun.servicetag.SystemEnvironment;
    SystemEnvironment se = SystemEnvironment.getSystemEnvironment();
            System.out.println(se.getCpuManufacturer());
            System.out.println(se.getHostId());
            System.out.println(se.getHostname());
            System.out.println(se.getOsArchitecture());
            System.out.println(se.getOsName());
            System.out.println(se.getOsVersion());
            System.out.println(se.getSerialNumber());
            System.out.println(se.getSystemModel());
            System.out.println(se.getSystemManufacturer());Edited by: emmanuel.putti on Nov 11, 2008 6:43 AM

  • How to setup the system monitoring using sol man ?

    Experts
    can any one advise me how to setup the below monitoing.
    Background jobs (SM50)         -  Long running jobs >24hrs
    Email/Fax  transmission(SCOT)  -  alert if there is any failire/errors in the email transmission
    iDocs Processing(WE05)          -  Data Transfer failure
    Enque locks (SM12)         -  alert if there are any Lock entries which are older than 2 days
    Update Records(SM13)         -  alert if there are any update request  older than 90 days
    Regards
    Karthi

    Hello Prasad
    Thanks a lot your information. I wil go thorugh the documents which you have mentioned.
    I have configured few alerts  and  unfortunately I am still struggling to configure these alerts. I am also not able find whether I will be able to configure these alerts are not. Any advice/tip  would be a great help.
    if I get some solution, definately I will share with all.
    Regards
    Karthi

  • How to Configure the system to use an firm's accepted warning banner in 10g

    Hello.
    I need to configure the system (oracle 10.2) to use an firm's accepted warning banner. I was able to do it in version 11 by putting entries in sqlnet.ora file. It then displayed when connectting as user (sys, system). I tried the same with 10.2 version and it doesnt display. Do i need to do anything different in 10g. I could not find the lead on googling it.
    I used theses entries in sqlnet.ora for 11g
    SEC_USER_UNAUTHORIZED_ACCESS_BANNER = <path>\banner2.txt
    SEC_USER_AUDIT_ACTION_BANNER = <path>\banner.txt
    Do we have to do differenetly in 10g. please help
    Thank you very much

    maggie wrote:
    Thanks for responding. Is there a way to create a banner in 10.2 version of oracle. I need to didpaly it as part of checklist i am working on for 10g.
    ThanksUnfortunately, auditors and security nazis dream up "requirements" without ever considering the capabilities and limitations of the selected technology. A lot of these guys get their technical knowledge from American Airlines Magazine when they get tired of reading the SkyMall catalog.
    Sometimes you just have to document the exception, get a manager's signature, and keep it on file.

  • How to read the Image Data using HTTp Request response

    i want to read image data from server please send me any code or answers.
    and also i want to exit application using button control for iphone simulator.
    thanks in advance.

    You would do a URLRequest and download the image. You could save it to disk and then load it or directly create a new image with the binary data.

Maybe you are looking for

  • Application testing using HttpUnit on SAP netweaver EP

    Hi, I'm trying to perform blacbox testing on login page of an application running on SAP netweaver server. The code in the testClass looks like this: URL serverUrl = new URL(url);         WebConversation conversation = new WebConversation();        

  • How do you create your own theme?

    I'm into astronomy and I'd like to create my own theme on my phone (6300) for when I'm at a dark site.  We use red light only at dark sites because white light ruins your night vision for longer.  How can I create a red-based colour theme/wallpaper/t

  • How to retrieve data from an Excel file which is located on server

    hi everybody,                 I am using SAP NWDS 2004s .                  I have done an application on how to export the table data into an Excel . Now i want to get the data from an Excel file which is located in server and display that data which

  • Download attachment speed in mail

    Hi all, I am experiencing something very annoying for quite a while. Whenever I receive emails with attachments it takes forever to download them. i.e I receive an 8megs email and am waiting forever. really 8megs...15minutes on a fast connection! Now

  • Report by mail

    Hello Experts, Could you please provide me steps to achive following. I have one report by "Sales Representative". I want to send report in mail to individual sales representative by for his performance only. In short I want to derive multiple report