menembus batas impian

insert dengan webservice


package pack1;

import java.sql.Connection;
import java.sql.PreparedStatement;
import javax.annotation.Resource;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.sql.DataSource;

/**
*
* @author nk
*/
@WebService()
public class customer {
@Resource(name = “customer”)
private DataSource customer;

/**
* Web service operation
*/
@WebMethod(operationName = “Create”)
public String Create(@WebParam(name = “username”)
String username, @WebParam(name = “drivinglicence”)
String drivinglicence, @WebParam(name = “creditcard”)
String creditcard, @WebParam(name = “firstname”)
String firstname, @WebParam(name = “lastname”)
String lastname, @WebParam(name = “physicaladdress”)
String physicaladdress, @WebParam(name = “phonenumber”)
String phonenumber, @WebParam(name = “password”)
String password, @WebParam(name = “location”)
String location, @WebParam(name = “Registrationdate”)
String Registrationdate) {
//TODO write your implementation code here:
String status = “Record not inserted”;
try
{
Connection con= customer.getConnection();
PreparedStatement ps=con.prepareStatement(“INSERT INTO Customer VALUES(?,?,?,?,?,?,?,?,?,?)”);
ps.setString(1, username);
ps.setString(2, drivinglicence);
ps.setString(3, creditcard);
ps.setString(4, firstname);
ps.setString(5, lastname);
ps.setString(6, physicaladdress);
ps.setString(7, phonenumber);
ps.setString(8, password);
ps.setString(9, location);
ps.setString(10, Registrationdate);
int i = ps.executeUpdate();
if(i!=0)
{
status=”Record Inserted”;
}
}catch(Exception e){
System.out.println(“Error in storing data”+e);
}
return status;
}

}

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: