Hi! OK this worked out. But i recognized some funny things:
>From the beginning:
I first used an algorithm that read the file and translated it's bytes into
a hex string (e.g.: byte fileByte=125 -> String hexByte="7D"). Then i had a
hex string which represents the file content and i saved it to the data
base like this:
String sql = "INSERT INTO myTable(fileName, data)
VALUES('"+file.getName()+"', X'"+fileContentAsHexString+"')";
If i compare the data fields of my algorithm with the data fields inserted
by FILE_READ(), thy have the same number of bytes (that says my h2 console).
But the data base file itself is almost doubled the size when i use
FILE_READ()!!!
Why is that?
Am Samstag, 25. Mai 2013 07:35:49 UTC+2 schrieb litailang xianghou:
>
> hi,
>
> try like this query.
>
> create table file(name varchar, data binary);
> insert into file values ('filename', file_read('/path/to/file'));
>
> litailang
>
> 2013/5/23 Andreas Fischer <[email protected] <javascript:>>:
> > Hey there,
> >
> > What is the nicest/fastest way to import a binary file content into a
> data
> > base table?
> > I have some binary files and i want to merge them into one data base
> table.
> > The key is the file name and a field of type BINARY named 'data' should
> > contain the exact copy of the file content.
> >
> > Thanks in advance.
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups
> > "H2 Database" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an
> > email to [email protected] <javascript:>.
> > To post to this group, send email to
> > [email protected]<javascript:>.
>
> > Visit this group at http://groups.google.com/group/h2-database?hl=en.
> > For more options, visit https://groups.google.com/groups/opt_out.
> >
> >
>
--
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/h2-database?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.