siddartha kandikonda

Greenhorn
+ Follow
since Jan 06, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by siddartha kandikonda

What is mean by string properties are retaining old values is that if i edit any text in the textboxes the changes are reflected in the string properties mapped to them while the boolean properties are not picking any change
12 years ago
I have a html form to which i have added a group of checkboxes using <html:checkbox> , on hitting the submit button the user is taken to a confirmation page in which the user has an option to go back to the actual form to edit any inputs.The problem i am facing is that once i check a checkbox the value(true) gets retained in the formbean property(boolean), it dosen't change even if i uncheck the checkbox. It beats me as to why only the booleans are retaining the old values, while other strings properties are not
12 years ago
Thanks winston for pointing me in the right direction,i just started looking at what JDBC offers for pagination
13 years ago
totally agree with you, there must be really easy ways to do this, this could be something unique to the kind of setup im dealing with.ok,let me see if im understanding this correctly, you are suggesting that JDBC can handle this out of box,its going to take care of giving me the set of records i want on each page,but is it going to fetch that 10K records at one go and hold it in cache?woudn't that hit my performance?
13 years ago
This post is about how to implement pagination when you have a very large number of records and you need to retrieve small chunks of records to be displayed on each page from the database at a time.note: this is a pure "from the scratch" approach and should be treated as the last resort i.e if nothing else works
my implementation was to display 50 records in each page(DB2 database in the backend) and the user should be able to navigate back and forth using "Next" and "Previous" buttons
Implementing "Next" button:
---------------------------------
This is the easier part of the implementation, assume you have a table with 2 columns Emp ID and Emp Name and Emp ID is the key, lets say you retrieved the first 50 records from the database in descending order(showing the latest employees first) on the first page , so if i have 500 employees in all, this will fetch records with Emp ID through 500-450, when the user clicks on "Next" you need to show records from 449-400 in the next page, all you have to do is get hold of the last record in the previous list and run a query, which goes something like this

select Emp ID,Emp Name
from employee
where Emp ID < 450
order by DESC
fetch first 50 records only

this can go on and on till you reach the last page ,

Implementing "Prev" button:
--------------------------------
This is a little tricky , lets suppose i am on page#3 viewing records from 399-350 ,if i want to go to page#2 which is records 449-400 , i need to get hold of the first record in the previous page and run a query like this

select Emp ID,Emp Name
from employee
where Emp ID > 399
order by ASC
fetch first 50 records only

here if you noticed i switched to "order by ASC" , this is the important because if i didnt order the records in ASC , this query would have fetched the first fifty records in the table i.e 500-450 , so by sorting in the reverse order and fetching the first 50 records i was able to get the records 449-400

however this implementation has a problem , this query will return the records in the order 400-449 , but in my pages i need all records to be displayed in the descending order , so you will have to reverse the order of the items fetched from the database in your java code, which can be done using Collections.sort() and Comparator , below is snippet of the code i used
Collections.sort(lstItems, Collections.reverseOrder(<Object>.<Name of the comparator>));

Agreed that this implementation will create a lot of database calls , but this works prefectly if you cannot fetch say 10K records at one go and handle the pagination on java side using lists etc
13 years ago
Well,my requirement was to decrypt the password to check if it matches what the user enters,since i was not able to do that,i get the encrypted form of the password user enters and compare it to the value in the table,this way i don't have to deal with the decrypting stuff,not a great idea but it works
Yes it works from the console,its in fact a pretty straight forward SQL,but somehow dosen't work with Hibernate,all i can say that Hibernate has got a problem handling VARCHAR FOR BIT DATA fields in DB2,the problem may be with the type of JDBC driver too,anyways i found a workaround for this problem after a few ruined weekends:-)
I have DB2 table which has a column holding encrypted passwords of data type VARCHAR FOR BIT DATA
i am able to store the password in this column using DB2 encrypt() function,so far so good,the trouble is when i try to read that password back using DB2 decrypt_char()
function,i am trying to do that using a Named Native SQL Query like the one below

SELECT decrypt_char(TEMP_PASSWORD)
FROM <table name>
WHERE LCASE(USER_EMAIL_ADDRESS) = :emailId

this gives me an exception and i am only posting the lines that are significant from the stack trace

Caused by: org.hibernate.exception.GenericJDBCException: could not execute query
Caused by: com.ibm.db2.jcc.b.SqlException: [ibm][db2][jcc][10150][10300] Invalid parameter: Unknown column name TEMP_PASSWORD.

i dont understand why,because not only is the column in present in the table but also the mapping is perfect in the hbm.xml
btw i am using a JDBC Type 4 driver and DB2 V9

any help would be great