java.sql and csvjdbc sorting

M

MyClue

Hey all,
I've gotten my csvjdbc driver working and can select rows. Is
there a SORTBY or ORDER BY in java.sql? It'd be nice to be able to
select by say... ID but sort by last name. Thanks!

--Mike
 
J

jagonzal

MyClue said:
Hey all,
I've gotten my csvjdbc driver working and can select rows. Is
there a SORTBY or ORDER BY in java.sql? It'd be nice to be able to
select by say... ID but sort by last name. Thanks!

Ummm... those are commands you should include in your SQL, as in
"SELECT * FROM table ORDER BY last_name".
 
M

MyClue

Too true... except stupid csvjdbc doesn't support ORDER BY or even
WHERE... :( As far as I can tell, it doesn't even support selecting
anything but SELECT *... i.e. I did "SELECT name FROM table" and it
selected everything. Kinda sucks. Thanks though.
 
M

MyClue

Too true... except stupid csvjdbc doesn't support ORDER BY or even
WHERE... :( As far as I can tell, it doesn't even support selecting
anything but SELECT *... i.e. I did "SELECT name FROM table" and it
selected everything. Kinda sucks. Thanks though.
 
J

jagonzal

MyClue said:
Too true... except stupid csvjdbc doesn't support ORDER BY or even
WHERE... :( As far as I can tell, it doesn't even support selecting
anything but SELECT *... i.e. I did "SELECT name FROM table" and it
selected everything. Kinda sucks. Thanks though.

Ah, the csvjdbc driver is "a bit" limited ;)

Easiest thing I can think of is insert the data into an Array and then
using the Arrays sort utility. Quick and dirty...
 
W

Web-Active

i found that when working with csv files and java, vectors come in very
handy, i find them much more dynamic than arrays, and the native
methods you can perform on vectors are quite handy. sorting is a
breeze, and comparisons on values are just as simple.

i usually pull any resultsets into vectors, perform any operations i
need to do on the data, and write it all back to a database or csv
file..... whatever suits best.

just build a java class that contains all your methods to translate
from resultset to vector, and from vector back to resultset, or
straight to csv string :p

i find it simplifies things to have 3 classes, keeping your code neat,
and reusable....

1. one class handles all db connectivity,

2. the other handles the compilations of a prepared sql statements, and
retrieving resultsets to vector or arrays,

3. and the 3rd handles your gui, input methods, and parsing of values
to your methods in your #2 class.

But thats just me... try out vectors.
 
M

MyClue

Sounds like some great ideas to me. We (my company) are thinking about
switching utilities/drivers to another utility since we're trying to
write as little supporting code as possible. (We need to avoid having
to train people if someone leaves) This whole project has been really
neat though.
 

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

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top