Database

Discussion in 'Java' started by kunju, Apr 2, 2006.

  1. kunju

    kunju New Member

    Joined:
    Mar 26, 2006
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    0
    HI,
    Pls help me..

    How to get the first record next record previous record and last from Database
    in java?
     
  2. coderzone

    coderzone Super Moderator

    Joined:
    Jul 25, 2004
    Messages:
    736
    Likes Received:
    38
    Trophy Points:
    28
    Why do you need that type of fetching from the database.
     
  3. kunju

    kunju New Member

    Joined:
    Mar 26, 2006
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    0
    I want to get display the item when I clicked the next button.So i need to get the nextrecord.
    if it is last should get any messge. Could you pls do me a favour too?How to add Images in to
    databases in Java?.Pls give me query. thanx.
     
  4. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,645
    Likes Received:
    87
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    http://blog.pradeep.net.in
    You can use the functions built inside the JDBC class for moving the cursor from & to wherever you want.

    Code:
    Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
                           ResultSet.CONCUR_UPDATABLE);
      ResultSet uprs = stmt.executeQuery("SELECT * FROM COFFEES")
      
      /* Move to first */
      uprs.first();
      /* Move to last */
      uprs.last();
      /* Next */
      uprs.next();
      /* previous */
      uprs.previous();


    There are more, which you can find here http://java.sun.com/docs/books/tutorial/jdbc/jdbc2dot0/inserting.html.

     
  5. kunju

    kunju New Member

    Joined:
    Mar 26, 2006
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    0
    thanks.
    How Can I add image(gif) to Database in Java?
     
  6. Amit Ray

    Amit Ray New Member

    Joined:
    Jul 12, 2004
    Messages:
    75
    Likes Received:
    4
    Trophy Points:
    0
    Occupation:
    Software Developer
    Home Page:
    http://www.go4expert.com
    Hi Kunju ...

    Can you please tell us what exactly you want to do? If you want to insert the binary information of the image in a database field you might want to use BLOBs (Binary Large Objects) to store the data in the DB.

    Depending on what DB are you talking about the implementation might vary a little.

    You can take a look at: BLOBs & Java

    Amit Ray.
     
  7. kunju

    kunju New Member

    Joined:
    Mar 26, 2006
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    0
    Hello,

    Actually what i am doing is a matrimonial work. I want to insert the image i.e
    photo into the Database. I am using MSAccess as backend. So I dont know the query which
    I want to use.Moreover, I want to search the image from the Database.I am displaying
    the image in the panel. And how to set the image into the panel after the search has been
    completed.I am searching one image at a time.So what query I should use?Could you pls give me a small example?

    I have experienced the following query. But it didnt work. May be my mistake.

    Image img=(Image)rs.getBlob("photo");

    is it wrong?I got the castexception . anyway pls give me example too.
    bye
     
    Last edited: Apr 4, 2006
  8. Amit Ray

    Amit Ray New Member

    Joined:
    Jul 12, 2004
    Messages:
    75
    Likes Received:
    4
    Trophy Points:
    0
    Occupation:
    Software Developer
    Home Page:
    http://www.go4expert.com
    Just wondering ... wouldnt it be much easier to save the url of the image in the database and use the url of the image to load it during run time ... The url can be anything from a directory on your local machine to a url on the web.

    Amit Ray.
     
  9. coderzone

    coderzone Super Moderator

    Joined:
    Jul 25, 2004
    Messages:
    736
    Likes Received:
    38
    Trophy Points:
    28
    I agree.
     
  10. kunju

    kunju New Member

    Joined:
    Mar 26, 2006
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    0
    hello,

    I am using stand alone application. Not web based. I am using only core java.
    pls give me any example of using image Database connection in Java.Also
    retrieval from the Database.Pls help me. Its urgent
     
  11. coderzone

    coderzone Super Moderator

    Joined:
    Jul 25, 2004
    Messages:
    736
    Likes Received:
    38
    Trophy Points:
    28
    You dont need any web based or anything to be using the image paths to be stored in the database.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice