kuldeep sidhu

Ranch Hand
+ Follow
since Jan 07, 2014
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by kuldeep sidhu

I have read other books - 97 things every Programmer should know and 97 things every architect should know.
This would be a great addition to this series of books.

Thanks Kevlin Henney, Trisha Gee for coming up with this book.

I have few questions -
Is this book contains contents similar to best practices in Effective Java? or  Is it at more abstract level? Does it contain any code examples or only things a Java Developer should be aware of?
I am curious about number 97. Whats special with number 97? why don't we have 100 things etc?
3 years ago
I am using in my project. I was trying to fetch records for last last week using annotation.


Native Query


Expected records should be 6 as I have records for 6 days in database.

JPQL Query is giving 6 records which is expected.
Native Query is giving 5 records, which is not correct.

But when I run the native query in my db tool, it fetches correct 6 records.
Using mysql as my database.

I am passing the value as '2018-05-22'. When I tried to debug native query is not fetching the records for 2018-05-22 even when I have condition as TRANS_DATE >= :date

Anyone have faced similar issue. What could be the possible reason.

Query printed by hibernate in both cases -

Native Query




Records in my database, fetched using sql query in my db tool.(First record is not coming when using Native Query)


5 years ago
I am using spring jdbctemplate to interact with Oracle database. For fetching multiple rows for a given condition, I want to store the result in a csv file having Column names as the header.

I tried few ways -

In customizedrowmapper, I am fetching the rows from result set and setting the fields in Bean class. I could not find any easy way to convert from bean to csv file. As I dont have access to bean class code.

2nd way I found was to writer ResultSet directly to csv file like below using opencsv library.

This is working okay, but it is skipping one row while writing to csv. I tried few queries. Manually, I can see 4 rows in the result, but in the CSV, it stores only three rows. Anyone faced a similar issue?

Or any other way we can achieve the same, without manually getting each record from ResultSet and making it comma-separated string and storing in file.
7 years ago
Thanks K. Tsang for the details.

I am planning for Oracle Certified Professional, Java SE 7 Programmer. But as far as I know there are two paths for this-
1. First complete OCA, Oracle Certified Associate, Java SE 7 Programmer and then go for OCP, Java SE 7 Programmer.
2. Complete Oracle Certified Professional, Java SE 6 Programmer and then upgrade it to OCP, Java SE 7 Programmer .

I am little confused here, should I go for OCA Java SE 7 first, or OCP Java SE 6.
What will be the recommended path..? or which would be beneficial for a developer point of view OCA or OCP ? And also if doing one of them(OCA/OCP) impact the job search in some way?

Jeanne Boyarsky wrote:The loop in your if statement and your else statement look exactly the same to me. I think you intended to reverse one.

I am using this in if condition

This is working as expected. I just get this working by debugging again and again. But to me, this seems bit complicated. Do you have any other simple way of doing the same.

And also i am bit confused about putting *. If i am adding it before printing the letter,it will add at the start of each line. And same with printing after the letter, it will append at the end of each line. How to achieve the desired output.
8 years ago
I am planning to go for Java Certification. I have been working with Java for a good amount of time. I have some doubts regarding the certification process.
Oracle Java Certification Page

As per above link there are three types
I want to know what is the difference between all of these. Is it levels of expertise or something else? or is there any kind of validation like you should have done some low level certifications if you want to go for another higher one.

This would be my first Java certification. So which one should I opt for?
Could you please give me the detailed idea about certification process and if any hierarchy is involved?

Thanks in advance.

I came across this small programming question of printing the following pattern

I was trying but i could not achieve it.
I was trying in the following way..

My thought is to if the line number is even, will print the letters in reverse order, but seems it is not working. Could someone please help.
8 years ago
I have created some REST web services. But have never implemented security.
What are the different ways of securing RESTful webservices? And which all of them you got covered in this video series?
Does this can be implemented using Spring Security module ?
8 years ago
I am able to get the desired output using the following regex -
This will either check for flow-control or end of line.
The captured text would be between Link speed...to flow-control or end of the line.
8 years ago
I tried this as you suggested

This selects the 2nd line properly but nothing is captured from first line.
8 years ago

Stephan van Hulst wrote:You could just add a optional comma to your lookahead, and make the quantifier after Link speed reluctant.

I tried but could not get it working..could you please post the regex you think will work.
8 years ago
Thanks Stephan. As per the logic we are putting these lines in arraylist(line per entry). So it iterates arraylist and run regex on that.

Could you please suggest something for the following scenario -

From this i want to extract the line starting with Link speed(It can be on new line or middle of line) upto the Flow-Control...(this part can or cannot be present)

So the desired output would be means first line full and from second line only link speed part exculding comma and Flow-control part..
I tried few ways..

regex Problem is this selects 2nd line till the end.

regex this also capture the comma before flow-control..

I believe the trick is that Flow-control.... line can be present at the end or not.
I know it would be easy, but i could not get it properly. I could not understand the working of this properly.
8 years ago

Stephan van Hulst wrote:You can do this with a zero width negative lookahead. Note that you can also make regular expressions case insensitive with the help of flags.

Thanks Stephan. I got a idea from your reply.
Actually i used negative lookbehind to achieve the desired output.
So here is the final regex i used -
This only selects the status value (UP in this case) from line 1 and 3.

8 years ago

fred rosenberger wrote:Does it have to be a single regex? I always find that if I go to a huge effort to write a very complicated regex to meet all the criteria, then a week/month later when the criteria changes I am screwed.

Can you instead write a regex that finds all lines that have "current status", and then have a second regex to filter those that have "protocol"? If your criteria changes, it's pretty easy to add another that also filters (for example) "media", or that also allows "previous status".

Thanks Fred.
No. I can not use multiple regex. I need to put this in already existing system which only accepts a single regex.
8 years ago
Could you please guide me in writing a regular expression that should match the following criteria..
Sample Text

From above sample i need to select llines having current status in those, but if protocol word is there on left, it should skip this line.

I tried a few ways
1. - This selects all the lines.
2. - This selects 2 and 4 line.
I want opposite of that. I want 1 and 3 lines to be selected.

I could not find how to negate the 2nd regular expression so that it only select lines 1 and 3.
8 years ago