How to insert into mysql the creation time and modification time from java?

first how?
Second what is better from create the date from java or do it from mysql?
thanks in advace
Pedro

One way is to use the GetDate function in mysql. This will set the date as you insert data. insert into table(date) values(getdate())
Anytime you modifiy the table just call the function again and update its fields.
Dont know which is beter to do. In java or on the database side.

Similar Messages

  • How to insert text in the middle of an existing textfile using java

    Hi,
    How to insert text in the middle of an existing textfile using java i/o streams??

    Mickie wrote:
    I shudn't delete the file...Then you will have the old file and the new file - do you want that?
    and I have to insert text not only at a single place ....got to do at many places in the text file!!then extrapolate on the procedure outlined in reply #1 .

  • How to create endpoint in the creation of webservice in webdynpro for java

    hi all,
    I have created a EjbModule project in webdynpro. Now when i create a new > other>webservie--> virtual interface, it is asking for an endpoint. How to create this endpoint

    Hi Pinki,
    Chk this link..
    http://help.sap.com/saphelp_nw04/helpdata/en/da/2bf042493ef54499a77394ef6be096/frameset.htm (Section abt Endpoints while Creating a Web Service for an Enterprise JavaBean)
    GS

  • How to insert into more than one table at a time also..

    hi,
    i am a newbee.
    how to insert into more than one table at a time
    also
    how to get a autoincremented value of an id say transactionid for a particular accountid.
    pls assume table as
    transactionid accountid
    101 50
    102 30
    103 50
    104 35
    i want 102 for accountid 30 and 103 for accountid 50.
    thank u

    @blushadow,
    You can only insert into one table at a time. Take a look here :
    Re: insert into 2 tables
    @Raja,
    I want how to extract the last incremented value not to insert.Also, I don't understand your thread title... which was "how to insert into more than one table at a time also.. "
    Insert, extract... ? Can you clarify your job ?
    Nicolas.

  • How to insert 10 rows at a time in the oracle

    how ti insert r update 10 query at a time in the oracle

    You can do a small test to find it out.
    SQL> set serveroutput on
    SQL> drop table t
      2  /
    Table dropped.
    SQL> drop table s
      2  /
    Table dropped.
    SQL> create table s(no integer, name varchar2(4000))
      2  /
    Table created.
    SQL> create table t(no integer, name varchar2(4000))
      2  /
    Table created.
    SQL> insert into s
      2  select level, rpad('*',4000,'*')
      3    from dual
      4  connect by level <= 10000
      5  /
    10000 rows created.
    SQL> commit
      2  /
    Commit complete.
    SQL> declare
      2     ltime integer;
      3  begin
      4     ltime := dbms_utility.get_time;
      5
      6     for i in (select * from s)
      7     loop
      8             insert into t(no, name) values(i.no,i.name);
      9     end loop;
    10
    11     ltime := dbms_utility.get_time - ltime;
    12
    13     dbms_output.put_line('Exec Time:'||ltime/100||' Seconds...');
    14     commit;
    15  end;
    16  /
    Exec Time:17.22 Seconds...
    PL/SQL procedure successfully completed.
    SQL> truncate table t
      2  /
    Table truncated.
    SQL> declare
      2     type my_type is table of s%rowtype;
      3     lType my_type;
      4     ltime integer;
      5  begin
      6     ltime := dbms_utility.get_time;
      7
      8     select * bulk collect into lType from s;
      9
    10     forall i in 1..lType.count
    11             insert into t values lType(i);
    12
    13     ltime := dbms_utility.get_time - ltime;
    14
    15     dbms_output.put_line('Exec Time:'||ltime/100||' Seconds...');
    16
    17     commit;
    18  end;
    19  /
    Exec Time:6.27 Seconds...
    PL/SQL procedure successfully completed.
    SQL> truncate table t
      2  /
    Table truncated.
    SQL> declare
      2     ltime integer;
      3  begin
      4     ltime := dbms_utility.get_time;
      5
      6     insert into t select * from s;
      7
      8     ltime := dbms_utility.get_time - ltime;
      9
    10     dbms_output.put_line('Exec Time:'||ltime/100||' Seconds...');
    11
    12     commit;
    13  end;
    14  /
    Exec Time:3.26 Seconds...
    PL/SQL procedure successfully completed.Thanks,
    Karthick.

  • How to insert into a table with a nested table which refer to another table

    Hello everybody,
    As the title of this thread might not be very understandable, I'm going to explain it :
    In a context of a library, I have an object table about Book, and an object table about Subscriber.
    In the table Subscriber, I have a nested table modeling the Loan made by the subscriber.
    And finally, this nested table refers to the Book table.
    Here the code concerning the creation of theses tables :
    Book :
    create or replace type TBook as object
    number int,
    title varchar2(50)
    Loan :
    create or replace type TLoan as object
    book ref TBook,
    loaning_date date
    create or replace type NTLoan as table of TLoan;
    Subscriber :
    create or replace type TSubscriber as object
    sub_id int,
    name varchar2(25)
    loans NTLoan
    Now, my problem is how to insert into a table of TSubscriber... I tried this query, without any success...
    insert into OSubscriber values
    *(1, 'LEVEQUE', NTLoan(*
    select TLoan(ref(b), '10/03/85') from OBook b where b.number = 1)
    Of course, there is an occurrence of book in the table OBook with the number attribute 1.
    Oracle returned me this error :
    SQL error : ORA-00936: missing expression
    00936. 00000 - "missing expression"
    Thank you for your help

    1) NUMBER is a reserved word - you can't use it as identifier:
    SQL> create or replace type TBook as object
      2  (
      3  number int,
      4  title varchar2(50)
      5  );
      6  /
    Warning: Type created with compilation errors.
    SQL> show err
    Errors for TYPE TBOOK:
    LINE/COL ERROR
    0/0      PL/SQL: Compilation unit analysis terminated
    3/1      PLS-00330: invalid use of type name or subtype name2) Subquery must be enclosed in parenthesis:
    SQL> create table OSubscriber of TSubscriber
      2  nested table loans store as loans
      3  /
    Table created.
    SQL> create table OBook of TBook
      2  /
    Table created.
    SQL> insert
      2    into OBook
      3    values(
      4           1,
      5           'No Title'
      6          )
      7  /
    1 row created.
    SQL> commit
      2  /
    Commit complete.
    SQL> insert into OSubscriber
      2    values(
      3           1,
      4           'LEVEQUE',
      5           NTLoan(
      6                  (select TLoan(ref(b),DATE '1985-10-03') from OBook b where b.num = 1)
      7                 )
      8          )
      9  /
    1 row created.
    SQL> select  *
      2    from  OSubscriber
      3  /
        SUB_ID NAME
    LOANS(BOOK, LOANING_DATE)
             1 LEVEQUE
    NTLOAN(TLOAN(000022020863025C8D48614D708DB5CD98524013DC88599E34C3D34E9B9DBA1418E49F1EB2, '03-OCT-85'))
    SQL> SY.

  • Read text file and insert into MySQL

    Dears,
    I need to read text file and then insert the data in the correct column in the MySQL database
    example
    I have the following text file:
    field1=1234 field2=56789 field3=444555
    field1=1333 field2=2222 field3=333555
    and so on and so forth ,,note that all rows are identical and just the filed value is changed(there is a dilemeter between fields)
    how can I read field1,field2 and field3 from text file and insert them in the correct table and column in the database.....
    any help?????
    thanks for your cooperation
    Best Regars

    Sure.
    Which part don't you understand?
    1. Reading a text file
    2. Parsing the text file contents.
    3. Relational databases and SQL.
    4. How to create a database.
    5. How to connect to a database in Java.
    6. How to insert records into the database in Java.
    7. How to map Java objects to records in a database.
    This is a pretty nice list. Solve complex problems by breaking them into smaller ones.
    %

  • How to convert the date time from MM-DD-YYYThh:mm:ss to YYYY-MM-DDThh:mm:ss format

    Hi All,
    I have a requirement in my project like to convert the date time from one format to another.my situation is like to convert the date time from MM-DD-YYYThh:mm:ss to YYYY-MM-DDThh:mm:ss format. I am using the soa suite 11.1.1.6.
    Can any one suggest me how to convert in the BPEL transformation.
    Thanks,
    Sanju.

    Hi Sanju,
    Store the date to be converted into a variable viz. dateVar. Now, process an expression in assign as: xp20:format-dateTime($dateVar,'[Y0001]-[M01]-[D01] [h]:[m01]:[s01]').
    Regards

  • Comparing the creation time of two jars.

    Hi,
    My requirement is that i need to compare the creation time of two of the jars and see which one of the jar is the latest.
    I did it using the following code i get the output in the form of strings so i cant compare them to find which one is the latest.
    import java.io.*;
    import java.util.*;
    public class FileTest {
         public static void main(String args[]) {
              File devbuild = new File(
                        "\\\\devspace\\dev$\\ReleaseEng\\DEVbuilds\\tw_enterprise\\build\\jboss\\Oracle\\Twelibrary.jar");
              File local = new File(
                        "D:\\jboss-4.2.1.GA\\server\\TWEServer\\Twelibrary.jar");
              Calendar now = Calendar.getInstance();
              int currtime = now.get(Calendar.HOUR_OF_DAY);
              int maxtime = 18;
              System.out.println("Before the while loop");
              while (currtime < maxtime) {
                   System.out.println("Inside the while loop");
                   if (devbuild.exists()) {
                        try {
                             // get runtime environment and execute child process
                             Runtime systemShell = Runtime.getRuntime();
                             BufferedReader br1 = new BufferedReader(
                                       new InputStreamReader(new FileInputStream(devbuild)));
                             BufferedReader br2 = new BufferedReader(
                                       new InputStreamReader(new FileInputStream(local)));
                             Process output = systemShell.exec("cmd /c dir " + devbuild);
                             Process output1 = systemShell.exec("cmd /c dir " + local);
                             // open reader to get output from process
                             BufferedReader br = new BufferedReader(
                                       new InputStreamReader(output.getInputStream()));
                             BufferedReader br3 = new BufferedReader(
                                       new InputStreamReader(output1.getInputStream()));
                             String out = "";
                             String out1 = "";
                             String line = null;
                             String line1 = null;
                             int step = 1;
                             int step1 = 2;
                             while ((line = br.readLine()) != null) {
                                  if (step == 6) {
                                       out = line;
                                  step++;
                             } // display process output
                             while ((line1 = br3.readLine()) != null) {
                                  if (step1 == 6) {
                                       out1 = line1;
                                  step1++;
                             try {
                                  out = out.replaceAll(" ", "");
                                  out1 = out1.replaceAll(" ", "");
                                  System.out.println("CreationDate: "
                                            + out.substring(0, 10));
                                  System.out.println("CreationTime: "
                                            + out.substring(10, 16) + "m");
                                  System.out.println("CreationDate: "
                                            + out1.substring(0, 10));
                                  System.out.println("CreationTime: "
                                            + out1.substring(10, 16) + "m");
                             } catch (StringIndexOutOfBoundsException se) {
                                  System.out.println("File not found");
                             //Long modifiedtime = devbuild.lastModified();
                             //long oldtime = old.lastModified();
                             int devbuilddate = Integer.parseInt(out.substring(0, 10));
                             int devbuildtime = Integer.parseInt(out.substring(10, 16));
                             int localbuilddate = Integer.parseInt(out1.substring(0, 10));
                             int localbuildtime = Integer.parseInt(out1.substring(10, 16));
                             if (devbuilddate >= localbuilddate && devbuildtime >= localbuildtime) {
                                  System.out.println("The Build date is Later than the one i am having--->");
                                  System.exit(6);
                             } else {
                                  System.exit(0);
                        } catch (Exception e) {
                             e.printStackTrace();
                   if (currtime > maxtime) {
                        System.exit(5);
    How can i do it?
    Can anyone help me out in this.
    Thanks,
    Kavipriya.

    Hi Clap,
    Thanks for ur reply. Let me say you the scenario clearly. We are in the process of automating some of the process. We have builds running daily night and our automation will run using that build.
    Currently the build which is getting generated does have manifest in it. For our automation framework we cant suggest adding the manifest. Which will not be agreed.
    Our automation will be checking till 10.am. to check whether the build is ready if not it will come out of the loop. If the build is avaialble within 10 then it will take the build and see whetehr the creation date and time of the build and the one i am having locally or different. If diff it will see whether the build generated is latest than the one i am having.
    If it so then the process will run.
    So hope you got my issue.

  • How to insert into a table in database1 from a table in database2?

    hi!
    how to insert into a table in database1 from a table in
    database2?
    can anyone help?
    Tariq.

    using the EXEC_SQL package.
    see form help for detail.
    Regards.

  • Help on Chinese insert into mysql (urgent)

    Dear Friends,
    we are running an coldfusion mx application on window,
    perfect, the database is mysql, utf-8 encoding.
    But when we moved to redhat linux +mysql, the chinese in the
    database displayed as ?????. when we insert into database, the
    chinese inserted like ????? as well...
    Any thing that we missed to config...please help.
    thanks,

    [This page|http://java.sun.com/developer/technicalArticles/Intl/HTTPCharset/] has a good explanation of where the issues might be.
    The thing with character encodings is that you have to get it right at every step. If you miss one of them, then the whole thing blows apart.
    From the minimal info you have here, I would take a look at the request.setCharacterEncoding() methd.
    cheers,
    evnafets

  • How to insert into a table from 3 tables?

    Hello,
    How to insert into a table getting values from 3 different tables?
    For example table_A has col_1 to col_10.
    I want to insert into table_A,
    values: col_1 to col_4 are from table_B,
    col_5 is from table_C,
    col_6 to col_10 are from table_D.
    Thanks!

    Normally, you'd do this by joining B, C, and D together. In the simplest case, something like
    INSERT INTO A( col1, ... col10 )
      SELECT B.col1, ..., B.col4,
             C.col5,
             D.col6, ..., D.col10
        FROM B,
             C,
             D,
       WHERE B.someKeyColumn = C.someKeyColumn
         AND C.anotherKeyColumn = D.anotherKeyColumnYou'd have to know how the data in B, C, and D relate to fill in the WHERE clause. This basically tells Oracle how to match the data in a particular row in B with the data in a particular row in C with the data in a particular row in D.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • How to insert icons in the selection-screen

    how to insert icons in the selection-screen?

    Mohan,
    Report zex33.
    type-pools: icon.
    selection-screen begin of line.
    selection-screen comment 1(20) text_001.
    parameters: p_werks type marc-werks.
    selection-screen end of line.
    selection-screen begin of line.
    selection-screen comment 1(20) text_002.
    parameters: p_whouse(10).
    selection-screen end of line.
    selection-screen begin of line.
    selection-screen comment 1(20) text_003.
    parameters: p_auart like vbak-auart.
    selection-screen end of line.
    initialization.
      write ICON_PLANT  as icon to text_001.
    concatenate text_001 text-001 into text_001 separated by space.
      write ICON_WAREHOUSE  as icon to text_002.
    concatenate text_002 text-002 into text_002 separated by space.
      write ICON_ORDER  as icon to text_003.
    concatenate text_003 text-003 into text_003 separated by space.
    Pls. reward for all useful answers........

  • How can I calculate the total time in java?

    Hello!
    I need to calculate the total time!
    For example I have start time:
              Format formatter1;
              Date date1 = new Date();
              formatter1 = new SimpleDateFormat("hh:mm:ss");
              String startTime = formatter1.format(date1);
              //startTime = "14:20:40";
    And I have finish time:
              Format formatter2;
              Date date2 = new Date();
              formatter2 = new SimpleDateFormat("hh:mm:ss");
              String finishTime = formatter2.format(date2);
              //finishTime = "08:30:55";
    So, after manually calculating, I get total time: "18:10:15"
    How can I calculate the total time in java? (Using formatter1 and formatter2 I suppose)
    What I need is to print "total 18:10:15"
    Thanks!

    800512 wrote:
    I did the following but, I think something is wrong here:
    I defined before: Date date1 = new Date(); Date date2 = new Date();
    And it should be exactly 5 seconds between them.
    I found delta between date1 and date2:
    Format formatter = new SimpleDateFormat("HH:mm:ss");
              long timeInMilliFromStart = date1.getTime() - date2.getTime() ;
              Date date3 = new Date(timeInMilliFromStart);
              String timeInSecFromStart = formatter.format(date3);
    and I get always
    //timeInSecFromStart = 02:00:05
    But it should be exactly 00:00:05.
    What can be a problem?Because, like I said, a Date measure an instant in time, not a duration. So when you have 5000 ms, and you turn that into a Date, that means 5 sec. after the epoch, which works out to 1/1/1970 00:00:05.000 GMT.
    As I mentioned, if you're not currently in GMT, then you have to set the TZ of the DateFormat to GMT. Right now, it's showing you the time in your TZ. If you included the date in your SimpleDateFormat, you'd see either 1/1/1970 or 12/31/1969, depending on which TZ you're in.
    Bottom line: You're trying to use these classes in a way they're not meant for, and while you can get the results you want for a limited set of inputs if you understand what these classes do and how to work with that, it's a brittle approach and comes with all kinds of caveats.

  • How can i get the System Time from the other host

    I want to get the System Time from the other host in the LAN,How can I get the Time using Java.
    Such as I am in WIN 2000 and I have a Unix host in LAN, I want to get unix host System time, How can I do it.

    Open a socket to port 13 and read a string with the time.
    -or-
    Open a socket to port 27 and read 4 bytes that are a network order timestamp
    Assuming that your UNIX machine has those services running, most do

Maybe you are looking for