Java

JDBC Handling Huge ResultSet

In this article lets discuss about querying huge database tables using JDBC api.

Consider a scenario where we have a huge database table with (say 1 million records), and the requirement is to display those records in your application UI.

Generally we will use the JDBC api in java to query the database table, iterate the ResultSet object and display the results in UI.

Http Post using Apache http client

In this article, let’s discuss about how to post data to any Http URL using Apache http client api.

HTTP protocol has two basic methods GET and POST.
• GET method is used to receive data from a Web server.
• POST method is used to send some data to the Web server.

Consider the following url,
http://localhost:8080/httppost/postDataReceiverServlet?userCount=10

When you navigate to the above url in the browser, it posts the data 'userCount=10' to the given web server/port.

Arun's picture

FTP4j - List Files in Remote FTP Server

In this section, the following Java FTP client connects to the remote server and lists all the files in the remote directory.

The below api has to be used for listing files in the remote directory.

FTPFile[] fileArray = ftpClient.list();

Java FTP – List Files

/**
    Copyright (C) 2011 TECHDIVE.IN

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either

Java - Thread scheduling using Scheduled Thread Pool Executor

The below Java class demonstrates the periodic scheduling of Threads using Scheduled Thread Pool Executor.

/**
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE IS DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

Java Create Cron Expression

The following code example provides a way to generate cron expressions in java.

/**
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

Web Application Auto Login

In general, every web application will have an authentication mechanism, to authenticate the users accessing the web application.

Suppose if there is a requirement to autologin to a web application from a given page, use the following code.

<html>
<head>
</head>
<script type="text/javascript">

function autoLogin()
{
var xmlhttp;
alert('loadXMLDoc');
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

Introduction to Ibatis

In this article lets have a brief introduction about Ibatis framework.

Before getting into IBatis, lets get to know the basics about ORM(Object Relational Mapping).

What is ORM ?

Returning excel from Http Response

In this article lets discuss about returning an excel file as part of Http Response.

Consider the following table. Lets return an excel sheet containing the following details as an Http response.

EMP_ID EMP_NAME AGE SALARY DEPARTMENT
1001 George 35 50000 IT

Arun's picture

FTP4j - File Upload

In this section, Let us see how to upload file from local directory to the remote FTP Server.

Perform the below steps to upload files to remote FTP Server.
1. Get the FTP Client object using IP address, username and password of the remote FTP server.
2. Create the File object to upload

File fileUpload = new File ("C:\sample.txt");

3. Use the below FTP4j api to upload files.
ftpClient.upload(fileUpload); // This will upload the local file to the remote server

FTP - File Upload
/**

Java - Pagination Utility

Consider a scenario, where you want to display a set of records from database in the User interface page. If the number of records is more, we would be using pagination to display the records. In this case we need to reform the SQL query to retrieve results for a particular page number with the limited records per page. For example, consider the following SQL query.

SELECT * FROM EMPLOYEES ORDER BY DEPT_ID,DOJ