Posts Tagged ‘How-To’

How To Reset MySQL Autoincrement Column

MySQL database provides a wonderful feature of Autoincrement Column index. Your database table can define its primary key as Autoincrement number and MySQL will take care of its unique value while inserting new rows.Each time you add a new row, MySQL increments the value automatically and persist it to table. But sometime you may want ...

How to iterate HashMap using JSTL forEach loop

JavaServer Tag library is one of the most used JSP tag library out there. I have used it almost in all of my JEE based projects. The best feature probably is the Iterator API in JSTL tag library.Here is a small code snippet which you might not know. Its very easy to iterate Lists using JSTL. For example://Java List<String> cityList = new ArrayList<String>(); cityList.add("Washington DC"); cityList.add("Delhi"); cityList.add("Berlin"); cityList.add("Paris"); cityList.add("Rome");request.setAttribute("cityList", cityList);//JSP <c:forEach ...
Tags: , ,

jQuery: Get the Text of Element without Child Element

While writing code in jQuery, I often use .text() method to get the content of any element from DOM. This function is straight forward, it strips off all the html element from a selected element and returns the remaining text.So for below element the .text() method will return "A quick brown fox".<div id="foo"> A quick brown fox </div> <script> $("#foo").text(); ...

Java: Convert Exponential form to Decimal number format in Java

While working with Doubles and Long numbers in Java you will see that most of the value are displayed in Exponential form.For example : In following we are multiplying 2.35 with 10000 and the result is printed.//Division example Double a = 2.85d / 10000; System.out.println("1) " + a.doubleValue());//Multiplication example a = 2.85d * 100000000; System.out.println("2) " + a.doubleValue());Result:1) 2.85E-4 2) 2.85E8Thus you can see the result is ...
Tags: ,

Dynamically shortened Text with “Show More” link using jQuery

Dynamically shortened Text with
Update: The plugin is now on GitHub: https://github.com/viralpatel/jquery.shortenFacebook user updates has a great functionality. If the comment text is larger than few characters, the extra words are hide and a show more link is presented to user. This way you can keep long text out of the view to user and stop the ...
Tags: , ,

Multiple Checkbox Select/Deselect using jQuery – Tutorial with Example

Multiple Checkbox Select/Deselect using jQuery - Tutorial with Example
Almost all the user interfaces that I have created had this functionality of selecting multiple items from a list to process them or delete them. Although its very very easy to implement this functionality in Javascript, using jQuery for this is real fun. I will show you a simple implementation of adding multiple checkbox select and ...

Calculate Free Disk Space in Java using Apache Commons IO

As a Java developer, lot of times I have to play around with file system. Sometimes I have to copy files/directories from one location to another; sometimes have to process certain files depending on certain pattern. In one of my test program, I wanted to calculate available disk space using Java. Lot of code snippets are ...

Java Tip: How to Sort Arrays in Java using java.util.Arrays class

Here is a small but very useful tip that every Java programmer should be aware of. Have you ever tried sorting arrays in Java? Well, java.util.Arrays class has built in method to make your job easy. You can use following method to sort any array in Java.import java.util.Arrays; ... ... Arrays.sort (int ) Arrays.sort (float ) Arrays.sort (long ) ...Let us check an example were we will sort an array of ...

Generating Random Data in Oracle

Most of the times, production data is not available in development environments. Here, I would like to share a single sql command which can generate random data. But before that, let's address another issue faced by a lot of new oracle users. We need to generate a sequence of numbers using a sql statement. This will generate a number sequence. ...

Deleting Duplicate Rows in Oracle

Deleting Duplicate Rows in Oracle
Deleting duplicate rows from tables is one of the common task oracle developers come across. The data might get duplicated because of missing primary/unique key on the table or batch file getting loaded multiple times. Here I have tried to summarize different ways of deleting this duplicated data. Please note that this is not an extensive list ...
Page 1 of 512345