Browsed by
Month: January 2016

What is the real meaning of overriding hashcode and equals methods in Java

What is the real meaning of overriding hashcode and equals methods in Java

What is the real meaning of overriding hashcode and equals methods in Java ? In many places we would have overridden hashcode and equals method without understanding deeply about it. Today after reading this post you will come to know,  Why we want to override hashcode and equals ?  What will happen if we override and if we won’t override ? where exactly we need to override the hashcode and equals methods ?Before going further, just understand these few terms,…

Read More Read More

782 total views, no views today

Change all words first letter to uppercase/lowercase in a string

Change all words first letter to uppercase/lowercase in a string

Change all words first letter to uppercase/lowercase in a string: When you are getting particular string from different source and like to format all the different source strings to some particular format like all first letter to uppercase/lowercase, you can make use of the below given java program. .toUpperCase() & .toLowerCase() toUpperCase and toLowerCase in java will convert all the letters to uppercase/lowercase instead of converting only first letter of a string. Java Program to convert all words first letter…

Read More Read More

491 total views, 2 views today

how to read csv file in java example?

how to read csv file in java example?

Title: Reading CSV File in Java Example Program CSV is abbreviation of Comma Separated Values. CSV file is also just a plain text file along with some delimiters [familiar one is ,]. It is used to store the data with comma separation. We have an option in excel also to export the column values as csv with comma delimited to share the file. Sample CSV File: Name, Profession, Place, Qualification Naveen kumar G, Developer, Chennai, BE CSE Sivachudar, Business Analyst,…

Read More Read More

524 total views, no views today

Java Program with Hibernate is not terminating

Java Program with Hibernate is not terminating

Java Program with Hibernate is not terminating: In hibernate you would have created the hibernate session factory to open the session and work with the databases. In that case you will face the program not termination issue sometimes. Rootcause: Once the program execution finishes session and sessionfactory should be closed, When it is not closed then you may face Java program not termination issue with hibernate. Quickfix: Close the session and sessionfactory at the last of the program execution. If…

Read More Read More

768 total views, 1 views today

No data was received to import. Either no file name was submitted

No data was received to import. Either no file name was submitted

No data was received to import. Either no file name was submitted, or the file size exceeded the maximum size permitted by your PHP configuration. See FAQ 1.16 Before going further first take the backup of the php.ini file which exists in the xampp/php folder. Root Cause: This issue will occur either of these reasons, 1. upload_tmp_dir parameter would have been in php.ini file which cause “no data was received to import error”. 2. Below parameter means that max upload…

Read More Read More

703 total views, 1 views today

[Solved] org.hibernate.NonUniqueObjectException

[Solved] org.hibernate.NonUniqueObjectException

org.hibernate.NonUniqueObjectException: A different object with the same identifier value was already associated with the session : [in.javadomain.ContentVO#0]   When I put my code like this, I got the above “org.hibernate.NonUniqueObjectException” exception, because session opening and closing has been done outside the for each loop which caused this nonunique object exception.   Set<ContentVO> extractedSaveSet = czc.getCouponsFrmCSV(); session = sessionFactory.openSession(); for (ContentVO content : extractedSaveSet) { session.beginTransaction(); session.save(content); session.getTransaction().commit(); } session.close();   So I changed it this way then issue got resolved.   Set<ContentVO>…

Read More Read More

490 total views, no views today

[Solved] JVM debug port in use issue

[Solved] JVM debug port in use issue

 JVM debug port in use issue: In Servers tab -> Right click on the server -> Administration -> Run Administrative console Now Administration console will be opened,   Servers -> Server Types -> WebSphere application servers -> CLICK_YOUR_SERVER[say myserver] -> Under Additional Properties section -> Debugging services -> JVM Debug Port (change to some port numbers (say 11119)) and restart your server. If the issue is not resolved still and if you admin rights then, Open Start Task Manager ->…

Read More Read More

1,815 total views, 1 views today

[Solved] org.hibernate.service.UnknownServiceException

[Solved] org.hibernate.service.UnknownServiceException

org.hibernate.service.UnknownServiceException: Unknown service requested[org.hibernate.engine.jdbc.connections.spi.ConnectionProvider] Rootcause: You will get this exception, at the line of opening the session which will be similar like this, session = sessionFactory.openSession(); If you would have closed the sessionfactory before the above mentioned line executes then you will get the “UnknownServiceException”. Solution: Ensure you did not close the sessionfactory before using it in next place and remove or comment if anything exists which resolves this “UnknownServiceException”. I got the same exception but I closed the sessionfactory,…

Read More Read More

717 total views, no views today

setLenient Example in Java date

setLenient Example in Java date

setLenient Example in Java date: In any programming language, handling date will always be challenging at some scenario. In Java we are using SimpleDateFormat to validate the date. If you see the below program it is behaving in a unexpected manner, which cause system/application instability, package in.javadomain; import java.text.ParseException; import java.text.SimpleDateFormat; public class DateSetLenientExample { public static void main(String[] args) { try { String inputDate = "29/11/2015"; SimpleDateFormat simpleDateFormat = newSimpleDateFormat("MM/dd/yyyy"); System.out.println(simpleDateFormat.parse(inputDate)); } catch (ParseException e) { e.printStackTrace(); } }…

Read More Read More

776 total views, no views today

How to calculate months between two dates in java using Joda ?

How to calculate months between two dates in java using Joda ?

  How to calculate months between two dates in java using Joda ? Joda Jar is the one of the opensource jar in java for date related validations and functionalities. Finding the months between the two dates has been a challenging task if we try to do only with Java. Same requirement can be done very easily using the Joda Jar. Months Between two dates using Joda Jar: package in.javadomain; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale;…

Read More Read More

583 total views, no views today