Skip to main content

Posts

Showing posts from December, 2011

Special keywords in Java

"Final" keyword http://renaud.waldura.com/doc/java/final-keyword.shtml http://www.javamex.com/tutorials/synchronization_final.shtml Note that storing a reference to an object in a final field only makes the reference immutable, not the actual object public final List<String> myList = new  ArrayList<String>( ); you can still modify "myList" as follows. myList.add("good"); But the following code is not possible myList = new ArrayList<String>( ); myList = some other list;   "Volatile" keyword http://javarevisited.blogspot.com/2011/06/volatile-keyword-java-example-tutorial.html http://www.javabeat.net/tips/169-volatile-keyword-in-java.html http://www.javamex.com/tutorials/synchronization_volatile.shtml

Insert/update into multiple rows (collections) in table MyBatis

Method 1 (only for insert) :  To add multiple record into "product" table The XML file is as follows <insert id="insertList" parameterType="HashMap" useGeneratedKeys="true"> INSERT INTO product (vendor_id, name ,description) VALUES <foreach collection="paramList" item="param" separator=","> (#{param.vendorId}, #{param.name}, #{param.description}) </foreach> </insert> The invoking Java code is as follows List products = new ArrayList(); HashMap<String, Object>  para = new HashMap<String, Object>(); Product product1 = new Product("vendor_id1,"pen","good pen"); Proudct product2 = new Product("vendor_id1,"book","good book"); products.add(product1); products.add(product2); para.put ("paramList",products); Integer status = mapper.insertList(para); Method 2: (work both for insert and update) You also

Java thread

Thread scheduling http://www.java2s.com/Code/JavaAPI/java.util.concurrent/ExecutorsnewSingleThreadScheduledExecutor.htm http://www.javapractices.com/topic/TopicAction.do?Id=247 http://kamleshkr.wordpress.com/2009/10/02/java-threads-callable-and-future/ Thread signaling http://tutorials.jenkov.com/java-concurrency/thread-signaling.html http://www.javamex.com/tutorials/synchronization_producer_consumer.shtml Interrupt threads http://www.techrepublic.com/article/interrupting-java-threads/5144546 http://blog.donews.com/maverick/archive/2005/08/10/502286.aspx http://agapple.iteye.com/blog/916837 Tutorials http://www.baptiste-wicht.com/series/java-concurrency-tutorial/

Serialization and subclassing in Java

http://www.javapractices.com/topic/TopicAction.do?Id=70 http://www.jguru.com/faq/view.jsp?EID=251942 http://mindprod.com/jgloss/serialization.html#SERIALVERSIONUID Object Construction in Serialization http://javapapers.com/core-java/object-construction-in-serialization/ http://extreme-java.com/serialization-super-class-and-constructors/

Test package cannot find Source package class JUnit Netbeans

Remove the "index" directory in cache of NetBeans For Window X and NetBeans version 6.9 the directory is at c:\\Documents and Settings\\ "username" \\.netbeans\\" 6.9" \var\\cache\\index Update: In netbeans 7.2 on windows 7 the cache is located in c:\Users\username\AppData\Local\NetBeans\Cache\ Open MS Explorer and type   %appdata% to get AppData directory Refence: http://developmentality.wordpress.com/2010/05/26/clear-your-cache-in-netbeans/ PS: this clear cache action can also solve other problems, such as : "cannot load pages in Web Pages Folder in Netbean project"; "cannot to find class name in Test package".