Reading / writing SQL BLOB data to DB

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

alia
Posts: 11
Joined: 26 Mar 2009, 15:27

Reading / writing SQL BLOB data to DB

Postby alia » 04 Jun 2009, 14:57

Hi all!

Is there an easy way or an example of accessing blob data from a smartfox server java extension? Id like to combine a few bits of my binary data together (since they are always accessed together) for space/speed.

I haven't seen anything to do with accessing blob data through DBManager / DataRow in the docs.

If there isnt a way - could I use java/sql/PreparedStatement or am I restricted to use only the DB Manager?

Cheers

Alia
sstark
Posts: 77
Joined: 21 Nov 2008, 16:06

Postby sstark » 04 Jun 2009, 21:38

IMO you should not use BLOB data anyplace, especially when running a multi-user server with high load. Blob = HUGE amount of data load, very bad idea.
alia
Posts: 11
Joined: 26 Mar 2009, 15:27

Postby alia » 04 Jun 2009, 22:17

sstark wrote:IMO you should not use BLOB data anyplace, especially when running a multi-user server with high load. Blob = HUGE amount of data load, very bad idea.


Please correct me if I'm wrong but I thought a blob could be a variable length? (anything from 0<2^16) - also I'm assuming any solution to the post would be transferable to tinyblob etc.

I'm just using it as a store for anon data (that only the client cares about) that will probably be never more than a few hundred bytes at most.

Thanks for the reply!

A
sstark
Posts: 77
Joined: 21 Nov 2008, 16:06

Postby sstark » 05 Jun 2009, 19:45

alia wrote:
sstark wrote:IMO you should not use BLOB data anyplace, especially when running a multi-user server with high load. Blob = HUGE amount of data load, very bad idea.


Please correct me if I'm wrong but I thought a blob could be a variable length? (anything from 0<2^16) - also I'm assuming any solution to the post would be transferable to tinyblob etc.

I'm just using it as a store for anon data (that only the client cares about) that will probably be never more than a few hundred bytes at most.

Thanks for the reply!

A


I'm sure you are right. The thing is that it's usually easier to save that level of information as a regular var type, and if not it's better to save the data as a file and deliver the file. This is just my experience, I avoid blob data like the plaque. You may know something I don't.

Also, SmartFox passes all information to the client via XML, which means it's all converted to string data during transmission anyhow.
alia
Posts: 11
Joined: 26 Mar 2009, 15:27

Postby alia » 05 Jun 2009, 20:09

Yeah that last bit is the killer - probably my biggest beef with smartFox so far. I ended up just going with TEXT instead of BLOB - partly because I haven't found a better solution and this at least will let me debug the rest of the game until I do. Besides its one search and replace if I need to change back again. :)

cheers,

A.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 06 Jun 2009, 07:43

alia
You can completely bypass the DbManager class and directly access the JDBC connection object by calling DbManager.getConnection()

This will still take advantage of the DbManager configuration and connection pool allowing total freedom of use. Always remember to close the connection when you are finished with it to return it to the pool.
Last edited by Lapo on 10 Jun 2009, 05:33, edited 1 time in total.
Lapo
--
gotoAndPlay()
...addicted to flash games
alia
Posts: 11
Joined: 26 Mar 2009, 15:27

Postby alia » 09 Jun 2009, 20:36

Ah perfect! - Thanks.

Return to “Server Side Extension Development”

Who is online

Users browsing this forum: No registered users and 15 guests