Posts

RESTful WebService Tutorial

Representational State Transfer  ( REST ) is a style of  software architecture  for  distributed  systems such as the  World Wide Web . REST has emerged as a predominant  Web service  design model. We will be building a REST application using Apache tomcat , Jersey , Eclipse . Below is the code for making a dummy application for Restful WebService using Jersey. To begin with first set up all the jars required for the application.  Click the below link to download all the jars. https://sites.google.com/site/balonideepak/lib.zip?attredirects=0&d=1 After that  create a client for making a hit to the app. Create a class like JerseyGetClient.java and paste the below code inside it : import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.WebResource.Builder; public class Je...

JDBC versus ODBC and other APIs

At this point, Microsoft's ODBC (Open DataBase Connectivity) API is probably the most widely used programming interface for accessing relational databases. It offers the ability to connect to almost all databases on almost all platforms. So why not just use ODBC from Java? The answer is that you  can  use ODBC from Java, but this is best done with the help of JDBC in the form of the JDBC-ODBC Bridge, which we will cover shortly. The question now becomes, "Why do you need JDBC?" There are several answers to this question: ODBC is not appropriate for direct use from Java because it uses a C interface. Calls from Java to native C code have a number of drawbacks in the security, implementation, robustness, and automatic portability of applications. A literal translation of the ODBC C API into a Java API would not be desirable. For example, Java has no pointers, and ODBC makes copious use of them, including the notoriously error-prone generic pointer "void *"...

Thin & OCI Drivers

Oracle provides two main types of drivers. The OCI driver. The OCI (type 2) driver consists of java wrappers to the low-level Oracle Call Interface (OCI) libraries used by utilities like SQL*Plus to access the database server. The OCI driver offers potentially better performance that the thin driver. It however requires the OCI libraries to be installed on the local machine. The "thin" driver. Also referred to as type 4 driver, the thin driver is a pure Java implementation of Oracle's networking protocol (Net8). Being self-contained, it may be used on any machine with--or without Oracle installed--or even distributed with application classes in an applet.

ClientAbortException java.net.SocketException Broken Pipe

Symptoms: The following error appears in the logs: WARNING : Exception Processing ErrorPage[errorCode=500, location=/500page.jsp] ClientAbortException: java.net.SocketException: Broken pipe   WARNING : Exception Processing ErrorPage[errorCode=404, location=/fourohfour.action] ClientAbortException: java.net.SocketException: Broken pipe Cause: The warning log basically means that the connection to the client browser is  aborted before the response is fully transferred. It is a harmless warning as  it can be due to transient network problems or the browser aborts/refreshes the  page before it loaded.

java.lang.UnsupportedClassVersionError: Bad version number in .class file? (Eclipse)

Image
Before hitting the solution let's get to know why this error occurs in java.So when JVM tries to load a class   and found that class version is not supported it throws  UnSupportedClassVersionError   and it generally  occurs if a higher JDK version is used to compile the source file and a lower JDK version is used to run the program. For example: if you have written your program using Java 1.6 and compiled also and now you run that program in 1.5 you will get the error   "java.lang.UnsupportedClassVersionError: Bad version number in .class file  [at java.lang.ClassLoader.defineClass1(Native Method)]". So now we come to how to resolve this issue in Eclipse. Right click on the project in Eclipse and click on Properties menu.After that click on Java Compiler menu. In right hand side uncheck use compliance check box and from the drop-down menu click the version you need .For me i have to select 1.6.After that click ok and clean your project.If again ...

Firefox search bar plugin

Image
Hi Guys, We can do a little fun with Firefox search bar .We can create our own search engine there. Here i am creating a simple example of how you can create your own plugin. Go to the installed directory of Firefox and locate the folder "searchplugins" .Open this folder ,here you will see all the search engines xml listed there. You can copy paste the below code and restart Firefox to see your search engine in the drop down of search bar list. <SearchPlugin xmlns="http://www.mozilla.org/2006/browser/search/"> <ShortName>MySearch</ShortName> <Description>Demo search by google.. < /Description> <InputEncoding>UTF-8 < /InputEncoding> <Url type="text/html" method="GET" template="https://www.google.com/search"> <Param name="q" value="{searchTerms}"/> </Url> <SearchForm > https://www.google.com/ < /SearchForm> </SearchPlugin> an...

Ant build file to compile and clean resources

Hi, Below is a example for showing how to compile ,clean and make jar file of a project. Here i have given just a brief introduction of the tags how to use them. Advance build file structure i will include in coming post. Example: <?xml version="1.0"?> <project name="classroom" basedir="."> <property name="projectname" value="classroom" /> <property name="srcprop.dir" value="conf" /> <property name="build.dir" value="./compiled" /> <property name="src.dir" value="src"> </property> <target name="usage"> <echo message="------------" /> <echo message="Building ${projectname} project..." /> </target> <!--Create  directory --> <target name="init"> <mkdir dir="${build.dir}" /> <echo message="Compiled Dir...