Skip to main content

Posts

Showing posts from January, 2013

JOINs in MySQL

JOIN's is used to query data from two or more than two table based on relationship between certain columns in these tables. Tables in Database are related to each other with some constraints like (Primary Key & Foreign Key) Primary Key :- Column with unique value for each row that is not value matching to each other in the column. Foreign Key :- Two tables are mapped through concept of primary and foreign key, that means primary key of one table is used in other table as foreign key. fig : Primary Key and Foreign Key Example Query to create the above two tables. CREATE TABLE `project_mst` (   `PK_PROJECT_ID` varchar(10) NOT NULL,   `PROJECT_NAME` varchar(100) default NULL,   `PROJECT_DURATION` varchar(50) default NULL,   `FK_MANAGER_ID` varchar(10) default NULL,   PRIMARY KEY  (`PK_PROJECT_ID`) ) CREATE TABLE `manager_mst` (   `PK_MANAGER_ID` varchar(10) NOT NULL,   `MANAGER_NAME` varchar(100) default NULL,   PRIMARY KEY  (`PK_MANAGER_ID`) )

Uploading data on Remote Server in Java

This blog demonstrate how to upload data from file to remote server/database. Follow the steps as shown. 1. Create new Dynamic Web Project. 2. Now create all the packages as show in the image below. 3. Create controller with name ImportContact.java 4. Create pojo with name Contact.java 5. Create database layer code with name ImportContactBroker.java 6. Create connectivity with name DBConnection.java 7. Create db connectivity setting file as connectionSetting.java 8. Create jsp page with importcontact.jsp 9. Create supporting files like Constant.java and CsvReader.java 10. You can download the war file and import in your workspace. 11. MultipartRequest in Servlet and inside jsp helps to upload file on the remote server. 12. Download sample csv file from here . 13. Create Table with name Contact in Database as given in configuration file. 14.Just compile and run the code. ImportContact.java package com.uploadfile.controller; import java.io.BufferedReader; impo

Creating Webservice in Java

What is Web Service? A Web service is a method of communication between two electronic devices over the World Wide Web. A Web service is a software function provided at a network address over the web or the cloud, it is a service that is "always on" as in the concept of utility computing. The W3C defines a "Web service" as "a software system designed to support interoperable machine-to-machine interaction over a network". It has an interface described in a machine-processable format (specifically Web Services Description Language, known by the acronym WSDL). Other systems interact with the Web service in a manner prescribed by its description using SOAP messages, typically conveyed using HTTP with an XML serialization in conjunction with other Web-related standards. Web services creation process 1. To create webservice you have to Download axis2.1.x 2. Open eclipse-> windows ->preferences as shown in screen print. 3. In preferences-&g

Creating Jar file in Java

Creating Jar file through Eclipse. 1. Create New Java Project in Eclipse as shown in below snap. 2. Now create your java(SampleJar)file [Name doesn't matter]. 3. Right Click on created Project and now click on Export and after that Navigate to java and select JAR file and after that follow the Instructions as shown in the window. and hence forth your JAR file is created for execution. 4. Now create new Java Project and import SampleJar.jar file which is created as shown in below image. 5. Create Java file TestJar and execute your program with created jar. TestJar.java package com.angad.testjar; import com.angad.jarfile.SampleJar; public class TestJar { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub SampleJar sampleJar = new SampleJar(); System.out.println("Square Method Called from JAR ==>"+sampleJar.square(10)); System.out.println("Cube Method Called from JAR ==>"+s