Friday, January 9, 2015

REST Web Service


-REST is alternative to SOAP and WSDL.

-Generally, the four primary HTTP verb are used as follows:

1.GET
Read a specific resource (by an identifier) or a collection of resources.
2.PUT
Update a specific resource (by an identifier) or a collection of resources.
Can also be used to create a specific resource if the resource identifier is know before-hand.
3.DELETE
Remove/delete a specific resource by an identifier.
4.POST
Create a new resource. Also a catch-all verb for operations that don't fit into the other categories.

- REST runs over HTTP (Hypertext Transfer Protocol)

-try this
  Facebook
           www.facebook.com/youtube
  https://graph.facebook.com/youtube
  https://graph.facebook.com/youtube?fields=id,name,likes

  GMAP
           https://maps.googleapis.com/maps/api/geocode/json?address=khamgaon&sensor=false
  Instagram
           http://instagram.com/developer
           click on-> API console
   

Thursday, January 8, 2015

Prepared Statement Java SQL Connection


import java.sql.*;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

public class demo123
{
public static void main(String[] args)
{
try
{

Class.forName("com.mysql.jdbc.Driver");

System.out.println("class found");
Connection con = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/test","root","root");
System.out.println("class found1");
PreparedStatement ps = con.prepareStatement("select (password) from users where username= ? ");

ps.setString(1, "vishal");
ResultSet rs = ps.executeQuery();

if(rs.next())
{
String pass=rs.getString(1);
System.out.println("pss->"+pass);
}

} catch (Exception e)
{
System.out.println("Exception--->"+e);// TODO: handle exception
}

}

}