Re: Newbie question: Importing .csv data into Java DB tables
- From: "Bjorn Abelli" <bjorn_abelli@xxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 26 Mar 2007 16:25:41 +0200
"GGP" <chaoborid@xxxxxxxx> 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
.
- References:
- Prev by Date: Re: Java Careers group
- Next by Date: Hibernate: Changing load() behavior (proxy/full object) at runtime?
- Previous by thread: Newbie question: Importing .csv data into Java DB tables
- Next by thread: [Hibernate] "order-by" attribute on <bag> requires SortedSet implementation?
- Index(es):
Relevant Pages
|
|