java.sql and csvjdbc sorting

Discussion in 'Java' started by MyClue, Aug 2, 2006.

  1. MyClue

    MyClue Guest

    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
     
    MyClue, Aug 2, 2006
    #1
    1. Advertising

  2. MyClue

    Guest

    MyClue wrote:
    > 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".
     
    , Aug 2, 2006
    #2
    1. Advertising

  3. MyClue

    MyClue Guest

    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.


    wrote:
    > MyClue wrote:
    > > 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".
     
    MyClue, Aug 2, 2006
    #3
  4. MyClue

    MyClue Guest

    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.


    wrote:
    > MyClue wrote:
    > > 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".
     
    MyClue, Aug 2, 2006
    #4
  5. MyClue

    Guest

    MyClue wrote:
    > 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...
     
    , Aug 3, 2006
    #5
  6. MyClue

    Web-Active Guest

    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.

    wrote:
    > MyClue wrote:
    > > 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...
     
    Web-Active, Aug 4, 2006
    #6
  7. MyClue

    MyClue Guest

    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.



    Web-Active wrote:
    > 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.
    >
    > wrote:
    > > MyClue wrote:
    > > > 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...
     
    MyClue, Aug 4, 2006
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. MyClue
    Replies:
    8
    Views:
    2,563
  2. ecoolone
    Replies:
    0
    Views:
    797
    ecoolone
    Jan 3, 2008
  3. Replies:
    2
    Views:
    1,489
    James Kanze
    Jul 6, 2010
  4. Jason
    Replies:
    0
    Views:
    411
    Jason
    Oct 4, 2006
  5. Tom Kirchner

    sorting by multiple criterias (sub-sorting)

    Tom Kirchner, Oct 11, 2003, in forum: Perl Misc
    Replies:
    3
    Views:
    510
    Michael Budash
    Oct 11, 2003
Loading...

Share This Page