• Post Reply Bookmark Topic Watch Topic
  • New Topic

Packaging oracle database rows and columns as bytes  RSS feed

 
vasanth kannan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

up vote
2
down vote
favorite
I am new to Java and I am looking for a way to package the data retrieved from oracle database as bytes. I am thinking of packaging the data as I read them from the database using JDBC. Unfortunately I wont know the number of rows I am going to get from the database. So the size is not fixed and hence I realized I can't use byte array. I found that ByteArrayOutputStream along with DataOutputStream can be used along with it. I would also like to read them back by each column and row.

I am would like to be able to do something like this:

    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    DataOutputStream w = new DataOutputStream(bos);
    w.writeInt(5);
    w.write(13);
    w.write("A string value");
    w.write(Oracle Timestamp);
    byte[] ba = bos.toByteArray();
And I should be able to read each value later which I am not sure how to do. For example I tried ByteArrayInputStream and DataInputStream but I am not able to read the second integer(13 in this case) and don't see how to read the timestamp or string either.

Am I doing it the right way? or is there a better way of doing this?
 
Norm Radder
Rancher
Posts: 2240
28
 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Please read this. Maybe you shou‍ld start by telling is what is unsatisfactory about the replies you already have on SO.
Thank you, Norm, for noticing.
 
vasanth kannan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Sorry, didn't even realize that's considered a bad practice! I was desperate to find an answer to the problem and just posted it at both places hoping someone would point me in the right direction. I posted it at more or less the same time at both the places.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!