Jeff Hemminger

Greenhorn
+ Follow
since Jun 15, 2007
Merit badge: grant badges
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jeff Hemminger

I've written a couple of articles on this here:
Wiring Quartz Beans
and here:
Wiring and Clustering Quartz

I will warn you that these are not perfect solutions, but perhaps they can get you started.
The Spring Forum suggests that there isn't an exact logging flag like there is in hibernate, but I believe setting logging to debug would show some of that.

Of course, like the above forum thread suggests, with JDBCTemplate, you're providing the SQL as the developer, so I don't completely understand why you would need that?
I assume you can access your mysql with the same credentials from another jdbc client? I like to use SquirrelSQL, because I can configure it to use the same drivers as my application.

Anyway, just want to verify that the issue isn't a connection issue rather than a spring issue.
I would second the references made by Hendy, and also point out that the Spring and Hibernate forums are also very useful.

Additionally, for specific implementation examples, I would recommend google code search or koders. Since Spring and Hibernate are so ubiquitous now you can find a lot of examples in search engines.
Jesper,
Thanks for your comments.
For the most part, you are correct.
If I were in Ranadhir's situation, I would first look for a commons collection solution because they often have exactly what I'm looking for, maybe something akin to Satou's solution.
If not, I would probably just iterate through the ArrayList, or secondarily implement your suggestion which was to write a utility class or method to save from writing the loop several times.
It would be ridiculous to use this kind of custom string-like object throughout an application, and I concede that in a software system you're likely to receive an ArrayList of Strings intact and would not want to convert all Strings to this type of object.
And for that, I'm sorry, I should have elaborated my intentions regarding this solution before posting it.
So what I should have said is , if you really do not want to manually iterate over an ArrayList and want to make use of a regex in the contains method, and you have no concern for anything else and are programming in your own little ivory tower, you can do something like below...



Obviously, ostentatious concerns about elegance, the founding fathers desires for use of the equals() method, and String optimalisations do not come in to play here.
16 years ago
oops, probably don't want to try and "extend String" since it's a final class. :-)

So, my solution would look something like this:

public class MyString {

private String myString;
private Pattern myPattern;

public MyString( String inputString, Pattern inputPattern ) {
this.myString = inputString;
this.myPattern = inputPattern;
}

public boolean equals( Object anObject) {
//use this to perform your regex

}

/* setters and getters */
}

Use a class like this instead of a String class in the ArrayList.
16 years ago
The arraylist method contains overrides AbstractCollection.contains. In the API, AC contains states:
"Returns true if this collection contains the specified element. More formally, returns true if and only if this collection contains at least one element e such that (o==null ? e==null : o.equals(e)).

This implementation iterates over the elements in the collection, checking each element in turn for equality with the specified element."

What this means to you is that the contains method is already doing the iteration work for you, and is using obj1.equals(obj2).

Therefore, I would suggest creating your own FancyString object that extends String and overrides equals to perform the regex that you'd like to perform.
16 years ago