Results 1 to 13 of 13

Thread: java to mysql

  1. #1
    thamizhisai is offline Member
    Join Date
    Apr 2008
    Posts
    16
    Rep Power
    0

    Default java to mysql

    Can anyone please give me a sample how to insert image to MySQL and retreiving it.

  2. #2
    sukatoa's Avatar
    sukatoa is offline Senior Member
    Join Date
    Jan 2008
    Location
    Cebu City, Philippines
    Posts
    556
    Rep Power
    7

    Default

    What did Google said?

    have you also post this in Database forum?
    freedom exists in the world of ideas

  3. #3
    Rgfirefly24 is offline Member
    Join Date
    Aug 2007
    Posts
    20
    Rep Power
    0

    Default

    actually i'm not 100% pos but you cant actually store an image in a database, but you can store the name of it.

    I.E.

    Insert into X VALUES("myimage.jpg");

  4. #4
    sukatoa's Avatar
    sukatoa is offline Senior Member
    Join Date
    Jan 2008
    Location
    Cebu City, Philippines
    Posts
    556
    Rep Power
    7

    Default

    Just a suggestion... im not sure if this is possible....

    What if you will encode the image data in your own pattern...

    eg. weird characters change to readable characters....

    And store the encoded data in the database...


    Maybe if implemented, you will expect more comparisons...
    1 for encoder, also 1 for decoder....
    freedom exists in the world of ideas

  5. #5
    Rgfirefly24 is offline Member
    Join Date
    Aug 2007
    Posts
    20
    Rep Power
    0

    Default

    the problem with encoding data to place into a database is selecting the right column datatype. Now it would be entirly possible to store an encrypted item in a database as long as you set it to nvarchar[MAX].

    that makes it inefficiant though. Its better to store the image filename and just retrieve it.

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    In simple word convert the image into binaries and store it in a database as a image(image data type)

  7. #7
    Rgfirefly24 is offline Member
    Join Date
    Aug 2007
    Posts
    20
    Rep Power
    0

    Default

    hrm interesting. Didn't know that there was an image data type.

  8. #8
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by Rgfirefly24 View Post
    hrm interesting. Didn't know that there was an image data type.

    Yes it's pal. Really nice to use it. A long time ago I used it to store a text message in a database. Because message comes as a binary stream, and can't get characters from there.

  9. #9
    sanjeevtarar's Avatar
    sanjeevtarar is offline Senior Member
    Join Date
    Apr 2008
    Location
    Jaipur(India)
    Posts
    318
    Rep Power
    7

    Default

    You can store images into DB by converting images into byte streams.
    sanjeev,संजीव

  10. #10
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by sanjeevtarar View Post
    You can store images into DB by converting images into byte streams.
    Yes, but the question is how to convert the image into bytes, using Java. DO you know a way Sanjeev.

    Using C++, it's possible. We can work in a byte level.

  11. #11
    sanjeevtarar's Avatar
    sanjeevtarar is offline Senior Member
    Join Date
    Apr 2008
    Location
    Jaipur(India)
    Posts
    318
    Rep Power
    7

    Default

    Quote Originally Posted by Eranga View Post
    Yes, but the question is how to convert the image into bytes, using Java. DO you know a way Sanjeev.

    Using C++, it's possible. We can work in a byte level.
    Yes pal you can do it easily... just convert the image into ByteStream and then using BLOB data type in db you can store it into db.

    please check the thread....


    Check It
    sanjeev,संजीव

  12. #12
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    Ah, got it. I remember work with BLOB at my C++ project. Thanks Sanjeev. And also thanks for the link.

  13. #13
    sanjeevtarar's Avatar
    sanjeevtarar is offline Senior Member
    Join Date
    Apr 2008
    Location
    Jaipur(India)
    Posts
    318
    Rep Power
    7

    Default

    Quote Originally Posted by Eranga View Post
    Ah, got it. I remember work with BLOB at my C++ project. Thanks Sanjeev. And also thanks for the link.
    It's my pleasure Pal.
    sanjeev,संजीव

Similar Threads

  1. java to mysql
    By thamizhisai in forum Advanced Java
    Replies: 1
    Last Post: 04-26-2008, 09:21 AM
  2. mySQL HELP!!!
    By ace84 in forum New To Java
    Replies: 0
    Last Post: 04-19-2008, 11:39 PM
  3. Replies: 2
    Last Post: 04-17-2008, 06:02 PM
  4. MySQL 5.0 data backup from java
    By sanjay_sharma77 in forum JDBC
    Replies: 1
    Last Post: 11-06-2007, 01:19 PM
  5. Mysql Help
    By Sumendra Maharjan in forum JDBC
    Replies: 1
    Last Post: 08-08-2007, 02:19 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •