background preloader

Java Good Stuff

Facebook Twitter

Travelling salesman problem: simulated annealing (with demo) - Algorithms and Data Structures. JDBC Paging Tutorial. This tutorial will show you how to boost performance by selecting results from the datasource, page by page.

JDBC Paging Tutorial

Implementation on MySQL: The SQL required to fetch only a specific portion of the results is: "Select Statement" LIMIT [PageNumber ,] PageSize PageNumber - is optional and starts with Zero (0). For example, we want to fetch Page number 3 from "some table" where page size is 25 rows: -- Or, Just select the first page (same as select the first rows) In Java, given any sql statement as string named 'sql', we can execute a statement as: st.executeQuery(sql + " Limit " + (pageNum-1) * pageSize + ", " + pageSize); For even better performance I recommend setting the following "hints" to the JDBC Driver: First, when using paging you should create the JDBC statement as "Scroll Sensitive" this means that the driver will not "miss" any new records that have been changed (i.e. deleted, added, updated) since the fetch of the previous page.

Driver Hints given to the Statement object: Home. How to Parse JSON in Java. Use json-lib, a library which adds JSON support to any Java program. json-lib can take a String and turn it into a JSONObject which can then be used to retrieve specific attributes. 1.

How to Parse JSON in Java

Add this dependency to your project: <dependency> <groupId>net.sf.json-lib</groupId> <artifactId>json-lib</artifactId> <version>2.3</version> <scope>compile</scope> </dependency> What does this mean? See How to Add a Dependency to a Java Project. JSC Downloads. This page provides downloads of JSC-related files and installation instructions.

JSC Downloads

The process of downloading software involves transferring files from this web site to your computer's local hard drive. Any software downloaded from this site is subject to the terms of use. Please read them before downloading files. In particular, note the disclaimer regarding computer viruses. The author of this software has taken reasonable precautions to ensure that it was developed in a virus-free environment.

Downloading instructions To download a file, click on its name in a Download line below (the size of the file is shown in brackets after the file name). What happens then depends on which browser you are using. A File Download dialogue window will appear asking "What would you like to do with this file? " You are advised to run your own anti-virus software on the downloaded file. Follow the installation instructions for the specific file (see below). The JSC library. Converting Between a BitSet and a Byte Array. Articles: Tuning Java I/O Performance. Articles Index I/O Performance By Glen McCluskey March 1999 This article discusses and illustrates a variety of techniques for improving Java I/O performance.

Articles: Tuning Java I/O Performance

Most of the techniques center around tuning disk file I/O, but some are applicable to network I/O and window output as well. The first set of techniques presented below cover low-level I/O issues, and then higher-level issues such as compression, formatting, and serialization are discussed. Note, however, the discussion does not cover application design issues, such as choice of search algorithms and data structures, nor does it discuss system-level issues such as file caching.

When discussing Java I/O, it's worth noting that the Java programming language assumes two distinct types of disk file organization. Home. Apache HttpClient. Apache HttpClient - Tutorial Copyright © 2008 - 2012 Lars Vogel Apache HttpClient This tutorial describes how to use the Apache HttpClient library for accessing HTTP resources.

Apache HttpClient

This tutorial is based on Apache HttpClient 4.1. 1. The Apache HttpClient library simplifies handling HTTP requests. You retrieve and send data via the HttpClient class. DefaultHttpClient is the standard HttpClient and uses the SingleClientConnManager class to handle HTTP connections. The HttpClient uses a HttpUriRequest to send and receive data. 2.1. The following examples do not necessary work out of the box as we do not provide the required backend for receiving the data. Decompress.java - jbzip2 - A Java bzip2 library. Java regex tester. New Adventures in Software » A Java Programmer’s Guide to Random Numbers, Part 3: Seeding. The trilogy concludes.

New Adventures in Software » A Java Programmer’s Guide to Random Numbers, Part 3: Seeding

This is the last of three articles about random numbers in Java programs. The series covers the following topics and also serves as an introduction to the random numbers package of the Uncommons Maths library: True Random Numbers and Pseudorandom NumbersStatistical Quality (making sure the dice are not loaded)Performance (because sometimes you really do need half a million random numbers a second)Different kinds of randomness (because not everything can be modelled by tossing a coin)Degrees of Freedom (is every possible outcome actually possible?)

Security (when not losing money depends on nobody knowing what happens next) Part 3: Seeding Part 1 of this series discussed different kinds of random number generators (RNGs), highlighted the issues with using the default Java RNGs (java.util.Random and java.security.SecureRandom) and introduced the Uncommons Maths library, which provides three fast, high-quality alternative Java RNGs. Degrees of Freedom One more RNG… Edu.rit.pj (Parallel Java Library Documentation) AWT: Work With Hex Colors in Java. Java 5 Concurrency: Callable and Future.