Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
The Mikado Method
this week in the
Agile and other Processes
forum!
JavaRanch
»
Java Forums
»
Java
»
Java in General
Author
how to compare row by row
Baktha Elumalai
Greenhorn
Joined: Mar 13, 2010
Posts: 28
posted
May 14, 2010 05:06:10
0
i have table Xydata i am getting gstime from the table
preparedStatement = conn1.prepareStatement("select gstime from xydata a inner join fm4features f on a.ID=f.ID where a.objectId= '18' AND a.clientId = '1' AND a.gstime > '2010-04-01 00:00:00' AND a.gstime < ' AND f.DataId='1' AND f.value = '1' GROUP BY a.gstime"); rs = preparedStatement.executeQuery(); List<String> date1 = new ArrayList<String>(); List<Integer> hh1 = new ArrayList<Integer>(); List<Integer> mm1 = new ArrayList<Integer>(); List<String> ss1 = new ArrayList<String>(); while (rs.next()) { String output[]; String temp[]; *String gstime = rs.getString("GsTime");* String Date= gstime.substring(0,10); String hh2 = gstime.substring(11,13); String mm2 = gstime.substring(14,16); String ss2 = gstime.substring(17,19); System.out.println("+Date +hh2+ +mm2+ +ss2"); }
we want to compare the time hh, mm row by row (if the row is repeated delete the row else row is printed.
if row is repeated delete the one row
ouput
2010-05-08 20 18 2010-05-08 20 18 2010-05-08 20 19 2010-05-08 20 19 2010-05-08 20 21
Final Output after compare row by row and delete duplicate row
2010-05-08 20 18 2010-05-08 20 19 2010-05-08 20 21
i need this type of ouput
please help me if any body know the idea
Regards
Bakthavachalam E
Istvan Kovacs
Ranch Hand
Joined: May 06, 2010
Posts: 100
posted
May 14, 2010 05:08:49
0
Why don't you filter out duplicates at the SQL level using SELECT DISTINCT?
James Sabre
Ranch Hand
Joined: Sep 07, 2004
Posts: 781
I like...
posted
May 14, 2010 10:03:33
0
Istvan Kovacs wrote:
Why don't you filter out duplicates at the SQL level using SELECT DISTINCT?
This has been suggested on at least one of his many cross posts (at least 5 to my knowledge) of this topic.
I agree. Here's the link:
http://ej-technologies/jprofiler
- if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
subject: how to compare row by row
Similar Threads
How to Compare two Calendar Objects.
java.util.Date
how do i compare row by row
how to convert string into string array
how do get particular date of total time
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter