Object3d got from a database

Started by Melssj5, July 12, 2008, 01:38:29 AM

Previous topic - Next topic

Melssj5

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

EgonOlsen

#1
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.

Melssj5

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

EgonOlsen

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?

Melssj5

Nada por ahora

EgonOlsen

MySQL should be fine when dealing with blobs. At least i can't remember having any issues with it regarding blobs.

paulscode

This sounds interesting.  Any chance I can see the source code when you finish this?

Melssj5

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

paulscode

Quote from: Melssj5 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.

LOL, np

Melssj5

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

Melssj5

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