byte []

Hi you all,I know this questions might have been asked a couple of times here but I am not been able to find a way of doing it. How can a get a stream of bytes from an byte[] ?Unfortunnately my java.io skills aren't that great... Any help is welcome.MeTitus
[293 byte] By [Me_Titus] at [2007-11-26 12:16:07]
# 1
java.io.ByteArrayInputStream
sabre150 at 2007-7-7 14:51:42 > top of Java-index,Archived Forums,Socket Programming...
# 2

In this case what I need to do is construct an sql statement to insert a blob into a database. I could use prepared stmts, but before you guys give that hint, I can do it at this time as it would delay some things here.

In c# a would just place the byte[] in the statement and that would work, but it looks that it is a bit different in java...

MeTitus

Me_Titus at 2007-7-7 14:51:42 > top of Java-index,Archived Forums,Socket Programming...
# 3

> In this case what I need to do is construct an sql

> statement to insert a blob into a database. I could

> use prepared stmts, but before you guys give that

> hint, I can do it at this time as it would delay some

> things here.

You won't like this but - use a prepared statement! There are methods on a prepared statement that make this easy!

sabre150 at 2007-7-7 14:51:42 > top of Java-index,Archived Forums,Socket Programming...
# 4

I know but I wasn't the one who started the application in the first place, and right now there isn't time to change that... it will be done latter eventually... I saw some method that does it, in the ResultSet interface, but I don't really don't know how to get this done without using prepared stat...

thanks sabre150

MeTitus

Me_Titus at 2007-7-7 14:51:42 > top of Java-index,Archived Forums,Socket Programming...
# 5

> I know but I wasn't the one who started the

> application in the first place, and right now there

> isn't time to change that...

If I want to drive a wood screw into a plank of wood I use a screwdriver not a spanner.

> it will be done latter

> eventually... I saw some method that does it, in the

> ResultSet interface, but I don't really don't know

> how to get this done without using prepared stat...

Then learn! 1Hour tops!

sabre150 at 2007-7-7 14:51:42 > top of Java-index,Archived Forums,Socket Programming...
# 6
Its not that I don't know, if that was the case, I am always keen to learn new stuff, but at the moment it is impossible to change our code,, I can't belive there isn't one way of doing it without...MeTitus
Me_Titus at 2007-7-7 14:51:42 > top of Java-index,Archived Forums,Socket Programming...
# 7

> Its not that I don't know, if that was the case, I am

> always keen to learn new stuff, but at the moment it

> is impossible to change our code,,

I dont' buy this! You have to change the code whatever happens.

> I can't belive

> there isn't one way of doing it without...

OK, spend the next week trying to put the screw in the plank of wood using a spanner. Then, when you have made a mess of the screw and the plank of wood, learn to use a screwdriver.

sabre150 at 2007-7-7 14:51:42 > top of Java-index,Archived Forums,Socket Programming...
# 8
Ok sabre150 a got it... it seems I have no other way of doing it, at least if I don' want to spend one week trying to figure out one way of doing it without reinventing the wheel...Many thanks ;)MeTitus
Me_Titus at 2007-7-7 14:51:42 > top of Java-index,Archived Forums,Socket Programming...