I am trying to import five simple .csv files into separate Java DB
tables using NetBeans 5.5, but I can't seem to do it. This strikes me
as something that should be extremely basic, so I apologise in advance
for these overly simplistic questions.
1) How do I do it? I'd prefer to import the data from the .csv file,
rather than writing individual INSERT commands for each row in SQL.
2) Is it possible to save an Excel file as an .xml file (or even
a .csv file, or equivalent) and use THAT as a database table within
the app.?
2a) If (2) is 'yes', can the same be done using MS Access tables?
I'm open to any/all advice; if there's a website that spells all this
out in clear (lay-person) detail, I can try to work through that. If
it's as simple as I think it should be, I'm grateful to anyone who can
offer their advice.
TIA,
GGP
|
|
0
|
|
|
|
Reply
|
chaoborid (5)
|
3/11/2007 11:27:55 PM |
|
"GGP" <chaoborid@yahoo.ca> wrote:
> I am trying to import five simple .csv files into separate Java DB
> tables using NetBeans 5.5, but I can't seem to do it. This strikes me
> as something that should be extremely basic, so I apologise in advance
> for these overly simplistic questions.
They're not as simple as it may seem, but as I haven't seen any answers to
your question, I'll give it a try...
> 1) How do I do it? I'd prefer to import the data from the .csv file,
> rather than writing individual INSERT commands for each row in SQL.
There's no "standardized" way of importing in such a way into a database, as
the DB's differ so much. Most "importing" rely on the DB's specific methods
of doing such a thing.
The bottom line is that even if the possibility exist for some DB's, they're
in practice mostly a simplified way of INSERTing the lines one by one behind
the scenes.
I haven't used Java DB myself, but with a quick glance at their
documentation, I would say that it should be possible by using Java DB's
built-in procedures
SYSCS_UTIL.SYSCS_IMPORT_TABLE or SYSCS_UTIL.SYSCS_IMPORT_DATA
But on the other hand, why writing *individual* INSERT commands for each
row? With a simple iteration you need to write the SQL INSERT only once, but
iterating it for each line you read in from the csv.
> 2) Is it possible to save an Excel file as an .xml file (or even
> a .csv file, or equivalent) and use THAT as a database table within
> the app.?
Yes, it is, but you can even use Excel itself as a DB.
Just use an appropriate driver.
One way is to use Sun's built in ODBC-JDBC-bridge, and via that using
Microsofts ODBC-driver for Excel. You can find tons of examples of that with
Google.
> 2a) If (2) is 'yes', can the same be done using MS Access tables?
Absolutely, exactly the same thing goes for that as for (2), but then of
course by using an ODBC-driver for the Jet database used by Access.
/// Bjorn A
|
|
0
|
|
|
|
Reply
|
Bjorn
|
3/26/2007 2:25:41 PM
|
|
On Mar 26, 9:25 am, "Bjorn Abelli"
<bjorn_abe...@DoNotSpam.hotmail.com> wrote:
Hi Bjorn,
Many thanks for your reply. Sorry I didn't respond right away--I
thought this question had died in obscurity ;)
> I haven't used Java DB myself, but with a quick glance at their
> documentation, I would say that it should be possible by using Java DB's
> built-in procedures
> SYSCS_UTIL.SYSCS_IMPORT_TABLE or SYSCS_UTIL.SYSCS_IMPORT_DATA
I was not even aware that there were built-in facilities to import
data. Thanks for the heads-up, I'll give it a go.
> Yes, it is, but you can even use Excel itself as a DB.
> Just use an appropriate driver.
>
> One way is to use Sun's built in ODBC-JDBC-bridge, and via that using
> Microsofts ODBC-driver for Excel. You can find tons of examples of that with
> Google.
Yes, I've started playing around with this, and it works like a
charm! Again, thanks for the advice. This is much more preferable to
working with .csv files. I can get nearly everything I need into
Excel files, which (as you suggest) I can then access through code.
> Absolutely, exactly the same thing goes for that as for (2), but then of
> course by using an ODBC-driver for the Jet database used by Access.
Again, thanks. I have a few large Access DBs that I'd prefer to keep
intact, as opposed to moving them to JavaDB (or whatever). One quick
question, though: will the Access schema be respected when calling the
db from a Java app. using ODBC/JDBC bridge (haven't tried this yet--
just wondering if I should expect issues)?
Thanks again,
Greg.
|
|
0
|
|
|
|
Reply
|
GGP
|
4/3/2007 4:18:06 AM
|
|
"GGP" <chaoborid@yahoo.ca> wrote:
> Again, thanks. I have a few large Access DBs that I'd prefer to keep
> intact, as opposed to moving them to JavaDB (or whatever). One quick
> question, though: will the Access schema be respected when calling the
> db from a Java app. using ODBC/JDBC bridge (haven't tried this yet--
> just wondering if I should expect issues)?
There shouldn't be any problems.
I haven't had any major issues using Jet/Access in Java apps, though I
*prefer* using databases with type 4 JDBC-drivers.
/// Bjorn A
|
|
0
|
|
|
|
Reply
|
Bjorn
|
4/3/2007 9:33:05 AM
|
|
|
3 Replies
705 Views
(page loaded in 0.006 seconds)
|