Posts

Sentimental Analysis : PART 1

Sentimental Analysis refers to identify, extract, quantify, and study affective states and subjective information. It helps to identify public emotion about certain topics/products. Humans are fairly intuitive when it comes to interpreting the tone of a piece of writing, but teaching a machine to identify emotion is tough. A negative sentence can be assumed by machine as positive.  For example, In case of sarcastic sentence "I have lost my watch again. That's brilliant", humans can easily tell that it's a negative emotion framed in sarcasm but machine can assume that it's a positive sentence without knowing the context. Applying the contextual information, machine can identify it to be negative emotion. Sentimental Analysis helps to gain insight from social data and to understand the consumer attitude and act accordingly.  VOC(Voice Of The Customer) applications are primarily used by companies to determine what a customer is saying about a product...
Basics of DataSource : Datasource is a name given to the connection set up to a database from a server . DataSource is an alternative to DriverManager for getting the connection .  We should prefer database connections getting from  a DataSource instead of a DriverManager. Using a Datasource you need to know only the JNDI name. The JNDI style is typical when using an application server or a web container Java Example for configuring and accessing a DataSource : -------------------------------------------------------- 1)  Configure the JNDI DataSource in Tomcat by adding a declaration for your resource to your Context in server.xml   <Resource name="jdbc/myoracle" auth="Container"               type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver"               url="jdbc:oracle:thin:@127.0.0.1:1521:mysid"             ...

Arrays.sort() and Collections.sort() NullPointerException

While sorting an array by using Arrays.sort()  or using Collections.sort() for sorting a list you can encounter a NPE (NullPointerException) . You might be thinking what went wrong ? So one of element in the array which have been  passed for sorting contains the null element. Similar with the list case also .So check for a null entry in your array or list before passing to these methods as parameter. Example 1 : String[] strarr={"abc", "def" , null}; Arrays.sort(strarr); Output 1: -------- Exception in thread "main" java.lang.NullPointerException at java.lang.String.compareTo(String.java:1167) at java.lang.String.compareTo(String.java:92) at java.util.Arrays.mergeSort(Arrays.java:1144) at java.util.Arrays.sort(Arrays.java:1079) at Test.main(Test.java:7) Example 2: List strlist=new ArrayList (); strlist.add("abc"); strlist.add("def"); strlist.add(null); Collections.sort(strlist); Output 2: ---------- ...

HIbernate CRUD operations

Below are some of the DB operations performed in Hibernate . First we need to get the SessionFactory  object . We can get the object like this SessionFactory factory= new AnnotationConfiguration().configure(hibernate.cfg.xml).buildSessionFactory(); 1) Insert : Session session=factory.openSession(); Employee emp=new Employee("empID","empName"); session.save(emp); 2) Delete: Session session=factory.openSession(); Employee emp=session.createCriteria(Employee.class).add(Restrictions.eq("empID","123")).uniqueResult(); session.delete(emp); 3) Update: Criteria criteria = session.createCriteria(Employee.class).add(Restrictionss.eq("id", 1)); Employee emp = (Employee) criteria.uniqueResult(); emp.setSalary(5000); session.update(emp); 4) Select: Session session=factory.openSession(); List empList=session.createCriteria(Employee.class).add(Restrictions.eq("company","Google")).list(); // Will get the li...

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...

Running all targets in ant through command prompt

Suppose you have an ant script build.xml to build the project which contains multiple targets inside it.If you are running the script through eclipse then you can enable or disable the targets by right clicking on build.xml and click on  " Run As " and in the popup window opened check or uncheck the targets. But how to do the same thing in command prompt. I have one little solution that worked for me. Suppose your build.xml contains some target like this :    <target name="init">   <tstamp>   <mkdir dir="${build}">   </mkdir></tstamp></target>   <target depends="init" description="compile the source " name="compile">   <javac destdir="${build}" srcdir="${src}">   </javac></target>   <target depends="compile" description="generate the distribution" name="dist"  >   <mkdir dir="${dist}/lib"  ...

Difference between Apache Server and Apache Tomcat

Apache is an HTTP server and Tomcat is a container . So Apache server can serve the  requests which are static in nature while Tomcat can serve the request which are dynamic. So if the pages are served in JSP/SERVLET then we have to use Tomcat container to interpret them. Similarly, if you will be using PHP then you need to add its support in Webserver. Webserver is used to just respond to the requests with feature such as load balancing, whereas containers( such as Tomcat) are used to manage the lifecycle of the pages generated using  JSP  and servlet.

Calling a URL with the help of HttpClient

Hi , You can call your jsp pages through HTTPClient .For that you just have to have commons-httpclient-*.jar. Any version of this jar will work. For the below code i was having commons-httpclient-3.1.jar. You can try the following lines to call your jsp page.. URL url = new URL("http://localhost/mywebapp/test.jsp")); HttpClient client = new HttpClient(); GetMethod get = new GetMethod(url.toString()); client.executeMethod(get); Other way is to make some timeout settings in Connection.For that you have to modify some connection properties like this: URL url = new URL("http://localhost/mywebapp/test.jsp"); HostConfiguration hcfg = new HostConfiguration(); hcfg.setHost(url.getHost(), url.getPort()); SimpleHttpConnectionManager connectionManager = new SimpleHttpConnectionManager(); HttpConnection connection = connectionManager.getConnection(hcfg); HttpConnectionParams conparams = connection.getParams(); conparams.setSoTimeout(timeout); conparams.setConnectionTime...

org.xml.sax. SAXParseException: Element type "web-app" must be declared.

Sometime you will notice these kinds of error messsges while deploying your web application to Tomcat.  org.apache.commons.digester.Digester - Parse Error at line 22 column 18: Element type "web-app" must be declared. org.xml.sax.SAXParseException: Element type "web-app" must be declared. at org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1213) at org.apache.xerces.validators.common.XMLValidator.reportRecoverableXMLError(XMLValidator.java:1807) at org.apache.xerces.validators.common.XMLValidator.validateElementAndAttributes(XMLValidator.java:3633) at org.apache.xerces.validators.common.XMLValidator.callStartElement(XMLValidator.java:1229) at org.apache.xerces.framework.XMLDocumentScanner.scanElement(XMLDocumentScanner.java:1806) at org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDocumentScanner.java:949) at org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:381) at org...

Getting back the dropped table back in ORACLE

You can get back the dropped table in ORACLE . To do so checkout FLASHBACK command. Here is a example below : First of all create a table.I am creating  a table with name First_Table. " CREATE  table First_Table(name varchar(20),id varchar(10)) " Then DROP the table using DROP command like this: DROP table First_Table And here comes the magic command to get back the dropped table: FLASHBACK TABLE  First_Table TO BEFORE DROP ;

Project facet Java 6.0 is not supported by target runtime JBoss

This problem will come due to a mismatch over the JDK version defined in the Project Facet for that particular project and the version ,the runtime server is having. This thing worked for me  . I am having Eclipse Helios and JDK 1.5 installed .Right click on the project in Eclipse ,click the properties menu, click the Project Facets.After clicking you will see in right side some listing will come and among them one entry will be for java.So click on the java property and you will be see a drop-down box .Change the version accordingly.I have changed it to 1.5 and it worked for me. Clean the project. Hope the solution works for you.....

WAP (Wireless Application Protocol)

Wireless Application Protocol  ( WAP ) is a  technical standard  for accessing information over a mobile  wireless network .U sers can  access information instantly via  handheld wireless devices  such as mobile phones, pagers, two-way radios, smartphone and communicators.  WAP supports most wireless networks. These include CDPD, CDMA, GSM, PDC, PHS, TDMA, FLEX, ReFLEX, iDEN, TETRA, DECT, DataTAC, and Mobitex. The WAP Architecture:   Any WAP enable system consists of : a) WAP Gateway b) the HTTP Web Server c) the WAP Device Birth of  WAP :  The Wireless Application Protocol (WAP) is a result of joint efforts taken by companies teaming up in an industry group called WAP Forum. On June 26 1997 Ericsson, Motorola, Nokia, and Unwired Planet took the initiative to start a rapid creation of a standard for making advanced services within the wireless domain a reality. In December 1997 WAP Forum was formall...

Unable to start Eclipse — can't open \Java\jre6\lib\i386\jvm.cfg

Uninstall your current running jre version and install higher one. I was using jre1.6 when i had this problem so i have uninstalled it and installed 1.7 it and the problem was solved.
HAVE A LOOK AT IT ........................................................... Life is a journey You are never dealt the hand you desire. You will come up against obstacles that are tough Questions that cannot be answered or A Relationships you will have problems in Your heart will beat, you will sweat You will cry your eyes out , and You will quit..., and try again Everything obstacle you see in life is achievable you must overcome the obstacles that are in you. To overcome yourself is the key to Happiness. Remember, Our deepest fear is not that we are inadequate, our deepest fear is that we are powerful beyond all measure.