> thanks alot Rhino for your help you were really really so much helpful
>
[quoted text clipped - 19 lines]
> 3- OLE may be usefull but still dont know any one have tried it before
> so prefere not to use it
Yes, I understand your concerns about each of these possible approaches to
storing the data in Access.
I've done a little more research on this issue and have some further
information for you.
I posted to comp.lang.java.databases to see if there is ANY database that
will let you store your 4 dimensional boolean array in it. No one was able
to suggest any such database. Now, that doesn't mean that a database with
this capability doesn't exist! Perhaps several databases can do what you
want but no one who is familiar with those databases saw the question. Or
maybe those people were too busy to answer the question. So I can't say with
any certainty that there is no database that can directly store an array.
I also did some searches in the DB2 manuals since I am primarily a DB2 user.
I found some information but it wasn't very clear so I posted to
comp.databases.ibm-db2 to get clarifications. I was told there by one of the
people from the IBM lab where they develop DB2 (for Windows/Unix/Linux) that
DB2 Version 8 does not support direct storage of arrays. Also, it will not
support direct storage of arrays in Version 9, which will be out soon. They
suggested that best approach was to convert the boolean array into a byte
array; then it could be stored in a BLOB datatype (a VARCHAR FOR BIT DATA
would also be possible if the array were smaller than it is). Converting the
data to a byte array is a very standard approach and has been used for
several years for many kinds of data. For example, if you wanted to store a
JPEG in a DB2 database, you would first convert it to a byte array and then
store the byte array in a BLOB datatype.
In the case of MySQL, I think you will need to convert your boolean array to
a ByteArrayInputStream, then use setByteStream() to store the
ByteArrayInputStream in a BLOB datatype. When you retrieve the data later,
you will need to use getBlob() on the result set for your BLOB column. Then
you will need to convert the blob value back to a boolean array; I think you
will probably need to convert the blob to a byte array first, then convert
the byte array to a boolean array. Please note that I have never tried
exactly what you are doing and my suggestion is only that: I _think_ it is
the right approach but it may not work. You may have to modify my suggestion
a bit and use different intermediate datatypes to accomplish your goal.
I _have_ stored and retrieved JPEGs and audio files in MySQL with code
similar to what I suggested for your problem so if it would help you, I
could post some fragments of that code. But my code isn't converting a
boolean array to a byte array input stream or a byte array to a boolean
array so I suggest you do some Google Group searches to see if you can find
some existing examples of the techniques you'll need.
> any how we have to submit a running programe the do this and save it in
> any kind of dbms by saturday
> since i just have experiance in MS Access , Oracle and MYSQL
> so i think i will download MYSQL dbms and its driver and try this thing
>
> thanks a lot for your help i just dont know how to thank you enough
You're very welcome! Good luck with your project!
--
Rhino
ali - 06 Jul 2006 19:53 GMT
Hi
Rhino
well i have done a test programe to do what i need in my project and it
worked very well thanks to god and to you and the others who helped me
in this post
if you are intrested of the code or for any one who may have the same
problem in the future here is the code to insert a 2 dimention boolean
array to blob in mysql
boolean barray[][]={{true,false,true},{false,true,true,true}};
Class.forName("com.mysql.jdbc.Driver");
con=
DriverManager.getConnection("jdbc:mysql://localhost/db1?user=root&password=899160");
stp= con.prepareStatement("insert into img values (?,?,?)");
stp.setInt(1,20);
stp.setString(2,"Hassan");
ByteArrayOutputStream bos = new ByteArrayOutputStream ();
ObjectOutputStream oos = new ObjectOutputStream (bos);
oos.writeObject (barray);
oos.flush ();
bos.close ();
byte [] byteArray = bos.toByteArray ();
System.out.println(byteArray.length);
stp.setBytes(3,byteArray);
stp.execute();
=======================================
and here is how to read it
Class.forName("com.mysql.jdbc.Driver");
con=
DriverManager.getConnection("jdbc:mysql://localhost/db1?user=root&password=899160");
st=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
rs = st.executeQuery("SELECT * FROM img");
rs.next();
System.out.println(rs.getInt(1));
System.out.println(rs.getString(2));
boolean result[][];
byte a[] = rs.getBytes(3);
ByteArrayInputStream bis = new ByteArrayInputStream(a);
ObjectInputStream ois = new ObjectInputStream(bis);
result=(boolean[][])ois.readObject();
=======================================================
well i think my next task will be to get the speed or the needed space
to be reduced but that will be another problem that i have to deal with
on my own
well thank thanks thanks very much for your greate help
good bye and tack care
Rhino - 06 Jul 2006 20:30 GMT
> Hi
> Rhino
[quoted text clipped - 60 lines]
>
> good bye and tack care
I'm glad to hear that your program is doing what is required now!
It was a pleasure to help :-)
--
Rhino