Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 

Executing Stored Procedure using Spring JDBC Template

Technology: Spring-jdbc is the abstraction framework, it take care the below following list:   1) Defining connection parameters 2) Open Connection 3) Specify the statement 4) Prepare and execute statement/prepared statement ...

What is Containerization in Java?

Running software in containers is gaining in popularity for developers. Containers are typically collections of pieces of software and environment, running together in a single system. Developers take these systems and test them in the form of co...

Java and Its Role in Shaping Big Data and IoTs Future

Data is, beyond question, among the most pivotal factors when it comes to running a successful business. This rising popularity of the potential of data has served as the gateway to the adoption of Big Data. While it throws open the window to use...

Top 7 New Tools that Every Java Developer Should Know Today

Platform independence! It’s one the major reasons of the ever popularity of the Java language. It’s no wonder that organizations of all sizes and types are integrating it into their processes, not to mention the fact that Android is r...

What is Factory Pattern?

Factory pattern is one of the most used design patterns in java with the help of this pattern you can create object easily by using this concept of oops. Example of Factory pattern : 1. Create an interface 2. Create class that 'll ov...

Travelling Salesman Problem

Hello!!! Travelling Salesman Problem is for finding the shortest possible root that visit every node in the graph and return to the origin point. It is used to find the shortest path. For example:- In this graph, Their is many way to rea...

How to Print All Leaf Node of Binary Tree

Hello Everyone!!!   In order to solve binary tree problem of leaf node, we should know that what is leaf node? Leaf node is node of the binary tree whose have no left and right child means whose left and right child is null. It...

Default methods and static methods uses in Interface.

We know that interface provide methods without body or functionality but in abstract class we can provide default functionality of methods. So in interface we can't give method body and can't declare ant static method. But in Java 8 no...

Comparator Interface in Java

Comparator:- Comparator interface  found in java.util package and it contains equals() and compare() method. It use the multiple sorting technique to write our own comparison logic and is used to sort the e...

Comparable Interface in Java

Comparable:- Comparable interface  found in java.lang package and it contains only compareTo() method. It use the single sorting technique to write our own comparison logic and is used to sort the elements on the basis of...

Facebook OAuth Authentication using Java

Hi, This blog is to help you to get Facebook Authentication through OAuth using Java. As Facebook is not offering any SDK for Java clients so with the use of a Json parser we are going to develop a small web application in order to u...

ThreadGroup Class

ThreadGroup in Java: It represents combination of threads within a group. A thread group can also include other thread groups .With the help of thread group we can easily suspend, resume or interrupt group of threads by a single method call. ...

Synchronized block

Synchronized block: Synchronized block is mainly used when there is a sharing of resources and it is used to lock an object for any shared resource so that at a particular time only one object can use that resource. By using synchronized block...

Main Thread in java

Main Thread: When we run a Java program  then main thread begins running immediately. It is created automatically. The main thread is the first as well as last thread in a java program to end. It is the main thread from which other chi...

HashSet Class

HashSet Class: It extends AbstractList class and implements List interface. It uses hashing technique to store data. It contains only unique elements. We can use HashSet class by importing java.util package. Example: import java.util.*...

LinkedList class

LinkedList class: It provides a linked-list data structure. It uses doubly linked-list to store elements. It extends the AbstractList class and implements List  interface. We can use LinkedList class by importing java.util package. Exa...

NOT LIKE in Hibernate Criteria

The Hibernate Criteria Not like, selects the records that don't match to the matching string given in like parameter. Example: Criteria criteria=session.createCriteria(Tickit.class); //Here you can pass class on which you want to perf...

Formatting date in different format in java

Formatting Date in java: There is a predefined format for dealing with dates in java , but suppose if you want the date in some other format other than the default one then you can use the SimpleDateFormat class of the java.text ...

Getting object values from json data

Getting object values from Json: If you have a data in Json format and you need to retrieve the object values from that day, it can be easily done using Java.   Lets see an example,  If you are using maven add the following ...

Pass Element ID that Triggers `onclick` Event to the Event Handling Function

When we apply onclick event to an element, sometimes we need to pass ID of that element to the event handling function. We can do this by passing id to function as this.id or we can pass the element itself. Example: In the below example I&...

Getting current url in jQuery

Sometimes we need to identify which is the current URL of JSP page to perform some functionality. We can do this very easily by adding the below line in you on load function:   $(function(){ var url = window.location.href; ...

Creating object in Json format using java

Json object: You easily write your object in json format with java . Json format is used because it becomes easy to exchange information in this form. It is easy to understand and easy to write. Lets see an example,  If yo...

Static and Dynamic binding in java

Static Binding: It determines the the type of object at early stage during the compilation itself, i.e. it tells that the object belongs to which class during the compile time of the program.  There is no ambiguity in deciding the type...

Printing current Date in Java

Date Class in java: There is a Date class in java under java.util package which can be used to print the current dates. There can be various ways to print the current date. Lets see with the help of example: import java.util.Date; ...

Convert Xml to Json format using java

Xml to Json conversion: Lets see with the help of example. Following jars are required for conversion: apache-commmons json-lib ezmorph Suppose we have the xml file with name demo.xml with the following data: ...

Setting limit for the no. of words per record in solr while fetching

Fetching records in solr: Once you have finished with indexing in solr, now you can perform search on your records with the help of queries. Go to the url: http://localhost:8983/solr/#/collection/query  There is box with q,&...

Instance Initializer block in java

Instance Initializer Block: There are two types of data members: static and instance data members.  Instance data members are those that belongs to instance of a class. i.e objects. Here comes the role of instance initializer block. It...

Is it possible to run program without main method?

Can we execute a program without using main? Answer is yes, we can run a program without using main with the help of static block. Lets see about static block first. Static Block: It is block which can be used to give initial values to t...

Export from a list containing objects to excel file in java

Suppose you have a list containing objects. You can export it to the excel file.  You will require the following jars for this: xmlbeans-2.3.0.jar poi-3.9-20121203.jar poi-ooxml-3.9-20121203.jar poi-ooxml-schemas-3.9-20121203....

Deleting documents in solr collection

Deleting documents: Suppose, you have collection with the name of demo and you have indexed your file in the server in this collection but you want to delete all the documents or some of them, then it is possible by two ways: Deletion by So...

Indexing in Solr Server

Indexing: Solr gives you a quick response and results because of indexing. What does this mean? It means that it searches index instead of the text to retrieve the results for you. In book , you search for the index in the index page of the...

Program to print pascal's triangle using a 2D array in java

Pascal's Triangle:   Program to print Pascal's triangle: import java.io.*; public class Pascal{ public static void main(String []args)throws IOException{ InputStreamReader isr=new InputStreamReader(S...

Solr update using solrTemplate for incremental value

In previous blog Solr Atomic update with incremental popularity, we have updated the solr incremental field using SolrDocument.    Now we will update it through solrTemplate. Here is the sample code: PartialUpdate update =...

How to disable mongoDB java driver logging

Go to mongodb configuration file and add following lines of code. @Configuration public class SpringMongoConfig extends AbstractMongoConfiguration{ static Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); sta...

Fetching String of specified length in solr

For fetching a string for a specific value and length, here are 2 ways to do that. First using @Query and another using solr Criteria. In the below code it first searches for the string match and then suing filters we have defined the length o...

Adding multipli core in spring with custom solr repository

Repository take solrtemplate to execute solr operations. Since we have multiple cores so we need to create multiple template and multiple repositories for each core. Following example explains it with 2 solr core Repository and custom imp...

How to make AJAX call in jQuery?

Sometimes we need to make AJAX call in our Web page. The purpose of AJAX call is that you want to get/submit data without refreshing your page or you want to submit your form by calling an API. We can do this very easily by using ajax() method of...

Statement interface

Statement interface: It provides methods to interact with database means using Statement interface we can execute SQL queries.The createStatement() is present in java.sql.Connection interface and it does not take any argument. To use Statem...

Solr Atomic update with incremental popularity

In solr we can create a field which can update as the related doc is searched by user. For that we need to add a field in schema.xml as: <field name="popularity" type="long" indexed="true" stored="true"/> In the below code we hav...

How to generate unique number for an email in JAVA?

Sometimes we need to generate a unique number for an emailId, for example when a user register then we need to generate a number by using that user can verify his EmailId. For this we can use SHA1 encoding method. Example - In the below method...

How to encode string using MD5 in Java?

Generally we need to encode the password in our Applications for security purpose and we can use MD5 for this purpose. Example - In the below method I'm encoding sting by using MD5 import java.security.MessageDigest; import java.secu...

How to sort ArrayList in Java?

Sometimes we want to sort a List based on some property. Suppose we have a List of UserModel and we want to sort List by firstName then we can do that easily by using Collections.sort() and Comparator interface. Example: In the below example I...

How to get year from a date in Java?

To get only year from a date you can use the below code. You can pass any date that you wan to change, I'm getting year from the date in the below example:    /** * Get year from Date * * @param createDate *...

How to get full date with time in Java?

To get the full date with time you can use the below code. You can pass any date that you wan to change, I'm getting date in full date format in the below example:     /** * Get full month day year format from Da...

String Comparison using equals() and equalsIgnoreCase():

equals() and equalsIgnoreCase(): Both are used to compare two strings for equality and both methods are of String class. equals() general form: boolean equals(Object str) It returns true if the invoking string and the string passed ...

How to identify whehter the zip file contains valid files or not?

Sometimes we need to find whehter the zip file contains valid files or not. Suppose you have a zip file which contains multiple file you want to upload that zip file only if it contains files having extension jpeg,jpg,png,gif,tiff only, so we can...

How to push values in array in jQuery?

Sometimes we need to insert valuse in an array, we can do this by using push() method of jQuery very easily. Example     <!doctype html> <html lang="en"> <head> <meta charset="utf-...

Error loading class 'org.apache.solr.handler.dataimport.DataImportHandler'

After starting solr if you get the following error, that means you need to make some changes in solrconfig.xml(of the core in which error occurred).   Open the xml and correct the path for solr-dataimporthandler-.*\.jar as <l...

java.util.Random Class

java.util.Random Class: java.util.Random class is used to generate random numbers. As we know random numbers are very useful especially in game development. In java we can generate random numbers in two ways either using java.lang.Math.random(...

Error: javax.servlet.jsp.PageContext cannot be resolved to a type

Running a Maven web project in eclipse was giving errors on jsp pages: javax.servlet.jsp.PageContext cannot be resolved to a type javax.servlet.jsp.JspException cannot be resolved to a type The server was running fine, even the project w...
prev 1 3 4 5
Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: