JDBC access File system?

M

Michael Borgwardt

Peter said:
Hi
How can we use JDBC to access a File system?

By writing an appropriate JDBC driver. Not that it would make any sense to do so.
 
W

Wendy S

Michael Borgwardt said:
By writing an appropriate JDBC driver. Not that it would make any sense to
do so.

Sure it would... the database I use at work [IBM's UniData] can address a
filesystem "directory" as a database file, each filesystem "file" is a
record. If they're text files, then each line is treated as a field. This
makes it really easy to deal with all sorts of data that make more sense in
text files than in a "real" database table, and when you're manipulating the
data you really don't have to think [much] about where it lives.

Go for it, although I once thought about writing a JDBC driver for that same
database, and got as far as reading the specification... it's not trivial.
 
M

Michael Borgwardt

Wendy said:
By writing an appropriate JDBC driver. Not that it would make any sense to

do so.

Sure it would... the database I use at work [IBM's UniData] can address a
filesystem "directory" as a database file, each filesystem "file" is a
record. If they're text files, then each line is treated as a field. This
makes it really easy to deal with all sorts of data that make more sense in
text files than in a "real" database table,

I still fail to see why anyone would consider this a good thing. It loses
you performance and data integrity, and if you need neither, why bother
making it look like a database?
 
T

Tor Iver Wilhelmsen

Michael Borgwardt said:
I still fail to see why anyone would consider this a good thing. It
loses you performance and data integrity, and if you need neither,
why bother making it look like a database?

So that you can interchangeably use a file (containing, say, test
data) or a database table (with live data) by simply changing driver
name and resource locator in some configuration file.
 
J

Jim Cobban

Peter said:
Hi
How can we use JDBC to access a File system?
thanks
from Peter ([email protected])

Obviously only certain files can possibly have a structure appropriate for
accessing using the JDBC interface, so to ask the question in a totally
generic sense, as you did, is pretty meaningless.

If you are talking about accessing a file containing tabular data, for
example in tab separated or comma separate value format, then you can load
the data into an Excel spreadsheet, name the range containing the values,
identify the named range as an ODBC source, and then use the JDBC-ODBC
bridge.
 
S

Sudsy

Jim Cobban wrote:
If you are talking about accessing a file containing tabular data, for
example in tab separated or comma separate value format, then you can load
the data into an Excel spreadsheet, name the range containing the values,
identify the named range as an ODBC source, and then use the JDBC-ODBC
bridge.

Gosh, but that's ugly! A number of companies make drivers available
which can read CSV and TSV files directly and make them appear as
JDBC data sources to an application. Updates tend to be a problem,
however.
Sorry, but I just can't fathom using such a convoluted mechanism as
you propose. An Excel spreadsheet as the exchange format? Ugh!
 
P

Peter

Hi
It would be a good idea. because:

JDO -> JDBC -> database is good
but JDO -> JDBC -> file system is also good

thanks from Peter


Michael Borgwardt said:
Wendy said:
By writing an appropriate JDBC driver. Not that it would make any sense to

do so.

Sure it would... the database I use at work [IBM's UniData] can address a
filesystem "directory" as a database file, each filesystem "file" is a
record. If they're text files, then each line is treated as a field. This
makes it really easy to deal with all sorts of data that make more sense in
text files than in a "real" database table,

I still fail to see why anyone would consider this a good thing. It loses
you performance and data integrity, and if you need neither, why bother
making it look like a database?
 
G

Gerbrand van Dieijen

Hi
It would be a good idea. because:

JDO -> JDBC -> database is good
but JDO -> JDBC -> file system is also good

In this case you could use something like HSQLDb:
http://hsqldb.sourceforge.net, it has a non-server-mode that enables you
to store data in one single file (+one config file and temp file), it is
java only and you're free to embed in your application (no GPL, but
BSD-licence). You can have shared read access for multiple applications to
one single file but (unfortunately) no shared write access to a single
file.
I have used in one of my applications and it works very fine.
 
M

Michael Borgwardt

Peter said:
Hi
It would be a good idea. because:

JDO -> JDBC -> database is good
but JDO -> JDBC -> file system is also good

Why would the second case be "good"?
 
C

Chris Uppal

Michael said:
Why would the second case be "good"?

Perhaps for a developer who is very used to doing database work, but is not
experienced at reading/parsing files.

Just as a developer who is used to files may be reluctant to move to the
unfamilar world of database access when another programmer would see the
problem as naturally calling for a database.

Of course, that's a slightly twisted use of the word "good"...

-- chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top