Author Topic: Object3d got from a database  (Read 6603 times)

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Object3d got from a database
« on: July 12, 2008, 01:38:29 am »
Hi, Can I make an Object3D from a database information, I mean, I want to save all the 3ds files and textures on a database as blob and reconstruct them to use them in jpct. I have no idea about this, any clues?
Nada por ahora

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Object3d got from a database
« Reply #1 on: July 12, 2008, 07:04:33 pm »
You need some tool to read the files and write them into the blob and vice versa. That should be sufficient. Depending on the database, blobs can be a bit tricky (on Oracle for example). However, what's the purpose of this? Personally, i wouldn't do this. I once did that myself with graphics, but i found it too cumbersome to use. I wouldn't do it again that way but simply store a reference to the file on the hard disc in the DB instead.
« Last Edit: July 12, 2008, 11:27:16 pm by EgonOlsen »

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Re: Object3d got from a database
« Reply #2 on: July 12, 2008, 09:13:18 pm »
The requirements of the project is that the 3d models have to be stored on a database and not as files in the server for security, but I guess I can save the file on non user visible folders on my web server. Maybe sme requirements have to be changed in order to achieve quickly the project.
Nada por ahora

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Object3d got from a database
« Reply #3 on: July 12, 2008, 11:29:20 pm »
It isn't that hard to write some code that reads/writes blobs. If the project requires it, then so be it. Which database server is that?

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Re: Object3d got from a database
« Reply #4 on: July 14, 2008, 03:52:14 pm »
It will be mysql 4.x.
Nada por ahora

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Object3d got from a database
« Reply #5 on: July 16, 2008, 12:09:57 am »
MySQL should be fine when dealing with blobs. At least i can't remember having any issues with it regarding blobs.

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: Object3d got from a database
« Reply #6 on: July 16, 2008, 12:21:39 am »
This sounds interesting.  Any chance I can see the source code when you finish this?

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Re: Object3d got from a database
« Reply #7 on: July 16, 2008, 02:19:48 am »
Pray for me to finishing it becausse I am not finishing my projects this days, jaja. I will try a bit to do it but if not I will better place the file on specific folders.
Nada por ahora

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: Object3d got from a database
« Reply #8 on: July 16, 2008, 03:05:04 am »
Pray for me to finishing it becausse I am not finishing my projects this days, jaja. I will try a bit to do it but if not I will better place the file on specific folders.

LOL, np

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Re: Object3d got from a database
« Reply #9 on: September 27, 2008, 02:14:53 am »
well I was thinking on serializing the object3d and saving it into a file then getting the file and reading its bytes and saving the array in the database, and viceversa. But I am doing unnecesary reads and writes from the harddisc. How can I get an object converted to a byte array?

I was checking the ByteArrayStreams and the StringBufferStreams with no luck.

there should be a way in the jdbc to do an insert of an Object directly.
Nada por ahora

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Re: Object3d got from a database
« Reply #10 on: September 27, 2008, 02:41:16 am »
Hi, I found this. Very interesting, at least for me.

A record can be inserted directly to the database using the Resultet and the insertRow method.

should be something like that:

        1.- getting the ResultSet rs
        2.- rs.moveToInsertRow();
   3.- rs.updateObject(int columnIndex, Object x, int scale)
        4.- calling to rs.insertRow ()

This should insert the object on the database. I will try it by tomorrow becausse I must go home before I got stabbed. If anyone have try it please post it.
Nada por ahora