Store and retrieve datetime using mysql

Hi
Am first timer in JSP and having a problem with datetime field. My requirement is that I have to store the date and time a message is posted in mysql database.
After the message is posted I have to retrieve the data and display it in a new page including the datetime field.
Trying this for a long time but not able to get. Any suggestions.
Thanks,
Sridhar

I am using the preparedStatement to insert into the database and retrieve from the database.
My problem is when i am retreiving from the database datetime are not coming.
my preparedSTatement looks like this.,
PreparedStatement insert1ps=con.prepareStatement("insert into topic_category values(?,?,?,?,?,?,?,?,?)");
insert1ps.setInt(1,topic_id);
insert1ps.setInt(2,article_id);
insert1ps.setInt(3,author_id);
insert1ps.setString(4,heading);
insert1ps.setString(5,article);
insert1ps.setDate(6,sqldate);
insert1ps.setInt(7,archives);
insert1ps.setInt(8,verify);
insert1ps.setInt(9,no_views);
I am using the above statements for inserting into the database.
PreparedStatement selectaa = con.prepareStatement("select tc.topic_description,tc.datetime,aa.fname,tc.topic_head,aa.lname,tc.no_views from topic_category tc,article_author aa where tc.author_id=aa.author_id and tc.topic_id="+topic_id);
ResultSet rss=selectaa.executeQuery();
<td style="{font-family:verdana;font-size:12;color:#03065f}">
Posted on :<%=rss.getTimestamp(2)%></td>
And using this statement for retrieving.
Is there any error in the above

Similar Messages

  • Can i store and retrieve image using sql command?

    hi
    the following is what i enter to store image in table using sql*plus
    however i encounter some errors as shown below.
    i wondered if i actually can use sql to store image and retreive image
    or i need other developer beside sql to do.
    create table img_storage
    (id     number primary key,
    image     ORDSYS.ORDImage);
    CREATE or REPLACE procedure ADD_image (tmp_id number, file_name varchar2)
    as
         obj ORDSYS.ORDImage;
         ctx raw(4000) := null;
    begin
         INSERT INTO img_classifier (id, image) VALUES (tmp_id,
         ORDSYS.ORDImage (ORDSYS.ORDSOURCE(EMPTY_BLOB(),
         NULL,NULL,NULL,SYSDATE,NULL),
         NULL,NULL,NULL,NULL,NULL,NULL,NULL));
         COMMIT;
         SELECT image into obj FROM img_storage
         where id = tmp_id FOR UPDATE;
         obj.importFrom(ctx,'FILE','IMGDIR',file_name);
         obj.setproperties();
         UPDATE img_storage
         SET image = obj where id = tmp_id;
         COMMIT;
    end;
    show errors;
    create or replace directory imgdir as 'c:\image\';
    exec add_image(1,'argvseng.jpg');
    BEGIN add_image(1,'argvseng.jpg'); END;
    ERROR at line 1:
    ORA-00001: unique constraint (SYS.SYS_C002717) violated
    ORA-06512: at "SYS.ADD_IMAGE", line 7
    ORA-06512: at line 1
    how to reslove the error as shown above.
    or sql does not support ordsys.ordimage such command.
    hmm very confused ....
    what is the difference bet using blob for image and ordsys.ordimage?

    This has nothing to do with intereMedia.
    This is a basic SQL issue.
    A primary key cannot have duplicate entries in a table as the error message suggests.
    Before you call your peocedure you can delete the row with 1 as the primary key, or call the insert peocedure using a primary key that is not being used.

  • Whats is the easiest way to store and retrieve files using a DB?

    Hello,
    I have a web application where my users need to upload and retrieve files(.doc, .ppt. excel). I want to store them in the database instead of on the server. Anyone have any ideas on the easiest way to do this?
    Thanks,
    Danny

    Well, there's a BFILE data type-- that allows you to store essentially a pointer to a file in the database, though the file itself would be stored externally.
    A better option would be to store the data either as interMedia Text or as a B/CLOB, so all the data from the file would be stored in the file. interMedia Text gives a number of benefits if you're going to be working with the data-- i.e. searching the data, etc, but the additional work & restrictions may not be worth it if you just want to get the data in and out of the database whole.
    Justin

  • How to store and retrieve XML messages in AQ using ESB/ BPE

    Hello,
    I am having a requirement which I feel should be fairly common - store and retrieve XML messages in AQ. However, I am struggling to decide which type of queue to use AQ or JMS...Here is the requirement
    1. In an ESB, I want to read different kind of files using file adapter. Different kind as in, having different structure or schema
    2. I want to create a queue that is capable of storing any kind of xml data. To this queue, I want to enqueue the message read in step 1.
    3. In another process, say a BPEL, I want to dequeue the message and write into a file. The filename is retrieved from one of the header properties. I want to dequeue using a stored procedure, not by using a JMS or AQ Adapter (reason being that these adapters poll the queue, and consume a message immediately. However, I want to consume the message only when there is a business need)
    My questions are:
    1. What kind of queue I should create in the DB (What should be its payload type...XMLType? )... I guess the answer would also determine the adapter to be used - JMS or AQ
    2. How I should map the xml data read from the file in step 1 to this adapter
    Any help is highly appreciated.

    You are right in suggesting that I dont need to store my XML data as xml in the DB...I dont want to too :) but its just that, thats the only option I can see at this time (the other track i am exploring is :
    File adapter(XML) -&gt; Convert to opaque (base64binary) -&gt; Enqueue opaque to JMS (aq$_jms_bytes_message) -&gt;Dequeue Opaque -&gt; Write file opaquely.
    In this I have hit the roadblock in trying to convert XML to base64binary...maybe some custom java function is needed...anyway)
    Coming back to this thread, where I am trying the following
    File adapter(XML)  -&gt; Enqueue as XML to queue  -&gt;Dequeue XML -&gt; Write file opaquely.
    PS: I think its important for me to mention that I am using SOA 10.1.3.1.0
    I tried the steps you gave...after creating the queue, I am trying to create a JMS adapter. But the queue I created doesnt show up in the browse window of destinations for the JMS Adapter..That had led me to infer that JMS adapter cant be used
    {color:#99cc00}CREATE OR REPLACE TYPE batchupdate_row_type AS OBJECT
    (update_queue_id NUMBER
    ,upc VARCHAR2(20)
    ,price1 NUMBER);
    {color}
    {color:#99cc00}CREATE OR REPLACE TYPE batchupdate_rec_type AS VARRAY(9999999) OF batchupdate_row_type;
    CREATE OR REPLACE TYPE payload_type AS OBJECT ( payload batchupdate_rec_type);
    EXECUTE DBMS_AQADM.CREATE_QUEUE_TABLE ( queue_table =&gt; 'jmsuser.batch_update_queue_table', queue_payload_type =&gt; 'payload_type');
    EXECUTE DBMS_AQADM.CREATE_QUEUE ( queue_name =&gt; 'batch_update_queue', queue_table =&gt; 'jmsuser.batch_update_queue_table');
    EXECUTE DBMS_AQADM.START_QUEUE ( queue_name =&gt; 'batch_update_queue'); {color}
    I also needed some opinion on whether the last step of my proposed solution ( Dequeue XML -&gt; Write file opaquely) is possible. As I want to develop a service oblivious of the structure of the file, I dont want to create a file adapter based on a particular xsd...so I want to write whatever xml I am getting from the queue....is this step possible

  • How to store and retrieve blob data type in/from oracle database using JSP

    how to store and retrieve blob data type in/from oracle database using JSP and not using servlet
    thanks

    JSP? Why?
    start here: [http://java.sun.com/developer/onlineTraining/JSPIntro/contents.html]

  • Store and retrieve image in database using WD Java

    Hi All,
    I have to store and retrieve an image in oracle database. I have gone through the below blog and forum...
    How to display an image, which is stored in a database?
    The specified item was not found.
    I am able to store image in byte format(oracle data type BLOB) and when i try to retrieve it i am not getting the image....Sorry for my poor technical knowledge.
    can some body help me, please......
    Regards,
    G.

    Hi,
    my code is working... I am able to upload and retrieve the image. But now I am getting the below exception...
    Exception from image insert>> java.sql.SQLException: Data size bigger than max size for this type: 6770
    Below is the code I am uing...
    ConnectDataBase condb=new ConnectDataBase();
        IWDMessageManager mgnr=wdComponentAPI.getMessageManager();
         IPrivateDBImageView.IVn_FileElement  fileelement =
                                  wdContext.nodeVn_File().getVn_FileElementAt(0);
                             IWDResource resource=wdContext.currentContextElement().getResource();
    InputStream in=resource.read(false);
    ByteArrayOutputStream bOut=new ByteArrayOutputStream();
                             int lenght=0;
                             byte part[]=new byte [ 50000 ];
                             while((lenght=in.read(part))!=-1)
                             bOut.write(part,0,lenght);     
              Statement  stmnt=null;
                   Connection con=null;
                   String strQuery=null;
                   String strProp_Details=null;
                   try {
                        con=condb.getConnection (mgnr);
                        stmnt=con.createStatement();
                   PreparedStatement pst=con.prepareStatement("insert into VMS_Image values(?,?,?)");
                        pst.setInt(1,4);
                        pst.setString(2,"srinu1234");
                        pst.setBytes(3,bOut.toByteArray());
                        pst.execute();
                        bOut.close();
                        in.close();
                        mgnr.reportSuccess("Inserted");
                   catch (SQLException e) {
         mgnr.reportException("SQLException from image insert>>"+e,false);
                   catch(Exception e)
                             mgnr.reportException("Exception from image insert>>"+e,false);     
                        finally
                        try
                        if(stmnt!=null)
                             stmnt.close();
                             stmnt=null;     
                        if(con!=null)
                             con.close();     
                             con=null;
                        catch(Exception e)
                             mgnr.reportException("Exception in Closing from image insert>>"+e,false);
    first I used byte of 101024, then 501024 and finally tried with byte of 50000. I am getting the above exception if the image size is more than 4kb....
    Regards,
    Srinivas.
    Edited by: srinivas sistu on Aug 1, 2008 2:26 PM
    Edited by: srinivas sistu on Aug 1, 2008 2:34 PM

  • How to store and retrieve chinese characters

    Hi, I am facing some problem in storing and retrieving of chinese characters from oracle,9i .
    This is the character i am trying to store into the database
    自动提款机网络
    while trying to retrieve it, it shows
    自?提款机网?
    ^ ^
    you can see the weird characters like ? at some places.
    here is the sample code which i can using to store and retrieve data from the database
    class testInsert
    public static void main(String[] args)
    try {
         DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
         Connection conn = DriverManager.getConnection ("jdbc:oracle:thin:@172.16.6.81:1521:JFPPTDB1", "citi_user", "citi_user");
         int employee_id = 12345;
    String ename = "自动提款机网络";
         oracle.jdbc.OraclePreparedStatement pstmt = (oracle.jdbc.OraclePreparedStatement)conn.prepareStatement("INSERT INTO employees (employee_id, last_name) VALUES (?, ?)");
         pstmt.setFormOfUse(2, oracle.jdbc.OraclePreparedStatement.FORM_NCHAR);
         pstmt.setInt(1, employee_id);
         pstmt.setString(2, ename);
         pstmt.execute();
    pstmt.close();
    pstmt = (oracle.jdbc.OraclePreparedStatement)conn.prepareStatement("SELECT last_name, employee_id from employees");
    ResultSet rset = pstmt.executeQuery();
              String name = "";
              while(rset.next())
                   name = rset.getString(1);
         int id = rset.getInt(2);
              System.out.println("the name is :"+name);
    catch (SQLException sqe)
              System.out.println("Java SQLException caught, error message="+sqe.getMessage());
    and the table in oracle is
    SQL> desc employees;
    Name Null? Type
    LAST_NAME NVARCHAR2(10)
    EMPLOYEE_ID NUMBER
    I am using classes12.zip for oracle,9i. Is there any database setting that i need to know to retrieve the chinese characters?.
    I have been facing this problem for quite sometime and it makes my life tough. Please help me in solving this issue.
    Thanks
    PD

    hi, can you retrieve the chinese character from your os? When it comes to the wild code of asian character, you should focus on the database/client character setting. you may ask more about it from your dba.
    have a nice weekend!
    eilison
    [email protected]

  • Document Management - store and retrieve

    Currently we are running on SRM 4.0 with SRM 5.0 server and Netweaver 6.4.   Our screens were developed using BSPs and running in SAP Portal 5.0 (soon to be 6.0, hopefully).   What is the recommendation for storing and retrieving documents?  There are SEVERAL postings on different sites, but not getting anywhere.  Some of the postings contain specific function modules (like Bapi_document_create2, CVAPI, O_Document_…) but were not found in our system.  We did find CL_BDS_DOCUMENT, but found the following statement "SAP currently recommends not using BDS or DMF. Even use of the other Knowledge Provider services should be evaluated carefully." within this site's documentation under Knowledge Provider section.  Can anyone refer us to some technical documents and hopefully sample code?

    Your question is not easy to answer. There are different options to store and retrieve documents. First of all it depends on the functionality you need on your documents. Since I have no experience with SAP KM I can only talk about the options within SAP NetWeaver.
    The SAP Knowledge Provider is divided into different part. The most basic part is the CMS API(Content Management Service) (All function modules starting with SCMS_*). This API allows the retrieval and storage of documents in terms of the SAP Knowledge provider document model where a document consists of components and each component corresponds to the content. With the CMS API you can store and retrieve those documents in a Content Server via the HTTP 4.5 interface.
    Such a content server can be an external archive system that is certified for the HTTP 4.5 API (a list is provided by the ICC), the SAP data base or preferably the SAP content server (coming with SAP NetWeaver).
    All document management services in SAP (SAP ArchiveLink, Business Document Service, SAP Records Management, Document Management System) are clients of the SAP Knowledge Provider CMS API.
    Now, in order to model documents, the SAP Knowledge provider comes with the SAP DMS API. This DMS API is used to model complex document models (attributes, relations, ...) based on a so called content model that can be modelled via the document modeling workbench (DMWB). Here, the document management services mentioned above behave different. The SAP Knowledge provider is only infrastructure. This infrastructure has specializations using this infrastructure. Here are the most important ones I know about.
    SAP ArchiveLink: This services offers the storage and retrieval of simple images and the service of linking those images to business objects. Those links are for example contained in the table TOA01.
    So, the main focus here is to be able to navigate from a business object to the related images. It further has a workflow integration. The classical example is the invoice related to an FI document.
    SAP ArchiveLink does not support any kind of document management functionality such as versioning and indexing. But, with the introduction of the SAP Document Finder, this can be done project specifically.
    SAP ArchiveLink comes with a nice document viewer for viewing stored documents.
    SAP Business Document Service: The business object serevice was designed to be a simple API for managing documents including simple versioning and indexing of images and documents.
    SAP Document Management Service: This is the specialization with respect to PLM. So, DMS has the focus on engineering documents but can also be used to store other images and documents. SAP DMS offers document management functionalities such as check-in, check out of documents.
    SAP DMS is using a classification service for classifying documents. It also has a very large BAPI API for the external access on those documents. As far as I know, SAP DMS is not part of SAP NetWeaver (therefore, you did not find CVAPI*).
    SAP Records Management: SAP Records Management can be used for document management but is more than that.
    Within Records Management it is possible to create hierarchical structures and to fill them with all kinds of documents. You can either integrate scanned images (via ArchiveLink) or you can use the SAP Records Management Document service provider offering some basic DMS functionalities such as versioning and indexing. The nice thing is that you can keep a whole structure of documents and even any other SAP objects such as business objects, transactions or URL's.
    A typical application example is a HR personnel file. We've already done a lot of projects on that.
    In the end, the choice of the document management infrastructure depends on the needs you have.
    If you simply want to store and retrieve documents without any document management functionality ArchiveLink or simply the SAP CMS API will do.
    If you need hierarchical structures for your documents and an integration with various business objects SAP Records Management would be a good choice.
    You will find quite a lot of documentation in http://help.sap.com about these services.
    Now, a last remark for web applications. Most of the GUI's of the upper applications are made for SAPGUI. So, here it is necessary to extend the SAP functionality by developing own applications. Since all services are using the CMS HTTP API for storing and retrieving the content you can always generate a URL for displaying the documents. Use SCMS_DOC_URL_CREATE for creating such a URL for example.
    I hope, that helps a bit.
    Torsten

  • LRv3.2 Networking with an Asst , How to store and retrieve updated work on Win7?

    LRv3.2 Networking with an Asst , How to store and retrieve updated work on Win7 Network?
    We have a working 1gig network in Win7 PRO 64-bit.  and using LRv3.2
    * How do I configure our Files or Cataloges "so"  ALL Edits are veiwable/edit to all?   (we don't work on the Same Shoot/Folder at the same time)
    I NEED to see,  ALL the LR  Edits  (is great with DNG files
    *** BUT,  what I cannot see if I remember correctly (with just the DNG sharing)  is the  CROP or Virtual Copys ... possibly the Brush edits.
    HOW, do I configure to be able to read and edit ...  ALL of the updated/saved  Edits???   (after it is done by my asst.)
    Is creating a New Catalog for EACH  shoot the way to go?   (not sure I like this idea)
    Right now everything is in one(1) catalog  ... and it's getting big ... BUT, this allows us to search , and group ... going way back.
    Would be nice to be able to still do this easily, and with what we have already done.
    With our one BIG Catalog ... not sure if two(2) can access this catalog over the Network at the same time?
    Even though we never Edit the Same Folder or Files at the same time.
    Or will that be a problem over a simple Win7 PRO network?
    Thank you,
    HG

    Aloha Bob,
    Saw your link.  thank you.
    At least I don't feel "alone"  LOL
    At this point ... I am looking for a  "cluncky"   Work Around?
    * I was thinking,  Maybe making a copy of  My Cataloge ...
    Deleting ALL the  Folders in LR  ... except for the one's  that  will be worked by the Asst.
    Then moving that file to the  Asst.  Computer.
    * NEXT,  pointing the  Folder that they are working on ... across the Network to the Servers Files.
    * After they work on it:
    *** IS THERE A WAY ...
    * To  take that Cataloge ... and UPDATE  my Main  Cataloge.
    THIS, is the STEP  ... I don't know how to do.
    Can someone Help me with this?
    Step by Step,  because I am clueless ....
    Talking UPDATE of everything worked on ... including   Virtual copys, and  CROPS.
    Thank you,
    HG

  • How to store and retrieve images from database...

    Hi All
    Anubody tell me plz how to store images in database using jsp.
    and how to retrieve tme.
    Plz reply...
    Anurag

    Exactly
    try the links below may be those might help u in store and retrieval any kind of file.
    http://www.mysqltalk.org/insert-blob-example-vt112861.html
    https://java.sun.com/j2se/1.5.0/docs/guide/jdbc/blob.html
    http://javaalmanac.com/egs/java.sql/GetBlob.html
    http://publib.boulder.ibm.com/infocenter/idshelp/v10/index.jsp?topic=/com.ibm.jdbc.doc/jdbc142.htm
    and a dearly advice friend please query google b4 you post any query out here.

  • How the store and retrieval in ServletContext will happen??

    Hello Sir,
    I am developing a chat application thats in Swing & servlets Now I am able to authenticate user and I am using ArrayList to maintain the names of the user globally my storing it in ServletContext
    How to store and retrieve ArrayList from Servletcontext
    And another thing is that we are having personal chat(1-to-1) also. But how to use the thread model is not known to us as we have not faced such a situation before
    So if you could suggest some example code or snippets ot certain links then it would be of great help to us
    Thanks
    Regards
    Monarch

    Hello
    thanks for your reply. Actually we are doing the same thing that u have mentioned in your reply.
    The thing we are trying to do is that when a user is logged in the particular servlet which is responsible for the authentiacation of the user will authenticate the user an then calls method in the Chatter class which is outside the servlet
    The Chatter class declares two mwthods addChatter() and getChatter()
    I am managing the currently logged users in Arraylist using this two mehtods above
    When the first user logs in his entry gets stored at the first position in the arraylist but when other user logs in then his entry overrites the entry of the first user instead of getting stored in the next position.
    The arraylist gets initialized when second user logs in. to overcome this problem i want to store the arraylist into the ServletContext so it will be unique for the whole application and will not get initialized
    So I want to know the process of storing and retrieving the arraylist fro the context
    Hope ull understand me and reply me
    Thanks
    Regards
    Monarch

  • I downloaded pages from the app store and I can use it on my Mac login but it doesn't show up when my wife logs in to her account? Were using the same computer, just different logins.

    I downloaded pages from the app store and I can use it on my Mac login but it doesn't show up when my wife logs in to her account? Were using the same computer, just different logins.

    No. You need to buy it for your Apple ID and for the other. You will have problems with updates

  • My ipod touch will not let me connect to the itunes store and i am using a wifi connection

    My ipod touch will not let me connect to the itunes store and i am using a wifi connection

    allison i had the same problem to but then i figured out! You have to put in a credit card number so you can purchase a game thats free or 0.99 cents or higher then you have to fill in other stuff then press next on your ipod touch or computer then it says you have succesifully created an apple id! And i hope this information will help out!!

  • How can I store and retrieve a Word file after it's been converted to a pdf?

    How do I store and retrieve a Word file after it's been converted to an PDF?  My file has been trapped in PDF"hell" assigned to a folder that cannot be opened or read, but when deleted, also deletes the original Word file...

    I think we need some more info here like, how are you converting to PDF. This is the Reader forum and it doesn't convert files to PDF.

  • Opera stores and recalls commonly used name address and numbers. Why not FireFox?

    Opera has a 'form filling' feature that stores and recalls many useful items like name, address, email addresses, numbers (like credit card numbers) and supports typing them by offering to complete an item from its stored data.
    This facility is sorely needed in Firefox. The stored data is supplied by the user once and recalled by Opera as needed in filling out a form.

    Open Firefox, bring up the browser options window, and go to the security tab. There is check box here that allows Firefox to remember search and form history. Be sure that box is checked, and that you allow Firefox to keep cookies and browsing history. This should enable Firefox to record your input data for later use.

Maybe you are looking for

  • Control Recipe Status

    Hi Everyone... Need your help urgently. When creating a process order; after i have only released the order and not saved it; a control recipe is created. Can anyone tell me what is the status of the control recipe at this juncture and how exactly is

  • EDGE is down.. how do i get voice mails?

    how can i get my voice mails if they are not showing up on my phone because the EDGE service has been down all day here in Minneapolis.

  • "INSERT ALL" bug

    Hello, Recently we have migrated from Oracle 9iR2 on Windows to Oracle 10.2.0.1 on 64-bit Linux. However, one of our scripts stopped working. Consider the following: INSERT ALL INTO Queries_Raw (q_type) VALUES (dummy)            SELECT dummy FROM DUA

  • Post BI System Refresh steps- RSA1 issue

    Hello All, I am doing the post system copy for BI system. We did our system copy for both BI and ECC in parallel. Now I am unable to Restore the Source system in RSA1 by right clicking, when i do that it i can get upto the steps where it prompts me t

  • My Image isnt showing up , why ?

    I tried changing things, but i have no idea what to do now.. javadoc is all in HTML/javascript Code, i dont get why... Heres The Code, please help me : * To change this template, choose Tools | Templates * and open the template in the editor. package