vicky chauhan

Ranch Hand
+ Follow
since Nov 27, 2008
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 vicky chauhan

Hello All,

I have data in a java object as data1, data2.

data1 and data2 together forms a composite key in myTable where I want to insert the object.

The writing is happening as a batch. Like 10 insert statements are prepared using 10 objects and are executed as a batch.

I want to insert the above data with the constraint: data1 + data2 should not already be present in myTable i.e. data1 + data2 should be unique --- if unique then write else just ignore.

The query I am using is:



Running above query independently for single set of data runs successfully.

However, while running in batch scenario I am getting "com.ibm.db2.jcc.b.ie: Non-atomic batch failure." error.

I think it has something to do with using SYSIBM.DUAL in batch scenario.

Please help!
Nik
Got the answer!! Thanks to T. J. Crowder!!

10 years ago
I am running this code:



I want to set the five variables above with the values returned in the list. How?

Thanks,
Nik

10 years ago

Raymond Tong wrote:
Why would you start with "\"" and end with "\"" ?
and what if your delimiter doesn't need escape character?



Thanks Raymond.. I found a solution.. I have posted it in the last comment in this post..
10 years ago

Roshan Ramesh wrote:Bit tricky. But still, it should not take much time to resolve.

Assuming that you came here for advise on the possible delimeters, let me know if the below code did helped you.




Here is how I did it:

String delimiter = "||";
Pattern pattern = Pattern.compile(Pattern.quote(delimiter));
String[] tokens = pattern.split(line);

This worked perfectly... and is more efficient too!! Thanks to Ray!!
10 years ago

Mark Spritzler wrote:My question is why does it rollback at all. If you policy is to skip records when an error occurs, to me means, any error, skip and continue on where you left off. Not go back to the first record.

Maybe your configuration for skip or transactions is off. I don't know much more about Spring Batch.

Mark



Hello Mark,

Thanks for the input!!

Spring batch writes to database in chunk/batch -- like 100 records at a time... So in case of an exception, it does not know which item of the 100 resulted in exception... So for the skip policy to work, it rolls back and starts over writing each item at a time... So that the item where error occurred is caught...

My question is, once the item is found, the rest of the items should again be written off as a batch...... which is not happening........

Say there are 1000 records, and error occurred at 4th record.. so once the 4th item is found, the remaining 996 records should be written as a chunk instead of one at a time...

I don't know any configuration is available to make this possible or whether this behavior is missing from spring batch!!

Nik
10 years ago
Hello All,

Say my commit interval is 1000.

And during writing I get a error at 990th record which is skippable as per skip policy.

So a rollback will occur and the writer will start again writing the same records from record 1.

However, this time, It is commiting on each record. It does not honour commit interval. This is making the job dead slow.

Why the behavior is like that ?? Am I missing something in my configuration ??

Thanks.
10 years ago
Hello guys,

I have following data:

1||1||Abdul-Jabbar||Karim||1996||1974

I want to delimit the tokens.

Here the delimiter being "||".

My delimiter setter is:



However, String[] tokens = line.split(delimiter); is not giving required result.

Please help!!

Nik
10 years ago
Got it!!

10 years ago
Hello All,

I have a class with a resource property of type Resource in spring (org.springframework.core.io.Resource)which takes a file object as input.



However, I am reading a remote document through another custom API which returns the contents of the document as a String.



I want to pass this xml as Resource in my setResource method. However, I don't know how can I cast String into Resource.

Any ideas ??

Thanks,
Nik

10 years ago
Hello All,

I have a xml file like:



I am reading the above file in POJO named Product. So two objects will be created from above file with properties name and price.

Issue: I want to include "reference" attribute present in "products" tag in all the "product" objects. How can I include this in castor's mapping.xml file ??

Please help!!

Thanks!
Nik
Thanks James.

I rechecked the specifications and "\W" is allowed.

Password should be atleast 8 character long and should have atleast 3 of the following four: uppercase letters, lowercase letters, numerics and non alphanumeric ("/w")


The expression I came up is:

(?=^.{8,}$)((?=.*\d)(?=.*\W+)(?=.*[A-Z]))|((?=.*\d)(?=.*\W+)(?=.*[a-z]))|((?=.*\W+)(?=.*[A-Z])(?=.*[a-z]))|((?=.*\d)(?=.*[A-Z])(?=.*[a-z]))(?![.\n]).*$”;

But I was looking for something still less complex and small


10 years ago
Hello James,

Thanks for your comment.

I will test the regular expression. When i said "i read somewhere" -- that was not specific to my requirement.. In general I read somewhere on the web that all special characters might not be valid in password... However, now I know that it depends on specific project.

Regards,
Vicky
10 years ago
Hello James,

Thanks for your response...

And I am sorry for the confusing requirement...

The requirement would be:

Password must contain atleast three of the following:

1) Uppercase Letters (A-Z)
2) Lowercase Letters (a-z)
3) Numerics (0-9)
4) All special characters which are allowed in a password (!, @, #, $, %, &) (I remember I read somewhere that all are not valid.. but don't know that was right or wrong)

Regards,
Vicky
10 years ago
We will have to wait for the gurus then I think...

Because i am working on a system which has in built code for various components like input field, multi choice list.. etc... So in input field component, there is a provision to set regular expression for validation... but it has to be a single expression... and I do not have access to actual code.. so can not do much towards that...

And when I was speaking "I do not get atleast 3 out of 5 part" --- I mean about myself.. I am not able to solve that part of the issue..

10 years ago