NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

I am making A web service through database and deploy it in server

 
Post new topic   Reply to topic    NetBeans Forums -> SOA Users
View previous topic :: View next topic  
Author Message
gaurav_007



Joined: 22 Sep 2011
Posts: 1
Location: india

PostPosted: Mon Sep 26, 2011 6:52 pm    Post subject: I am making A web service through database and deploy it in server Reply with quote

I am making a webservice through a database in mysql in which i insert the data in database but i faced an error .I AM ENCLOSING SNAP IN PPT .



Can anybody help me in this context.Source Code is below:




package hello;

import javax.ejb.Stateless;

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







@WebService(serviceName = "newWebservice1")
@Stateless()
public class newWebservice1

{


@Resource(name = "data1")
private DataSource data;

@WebMethod(operationName = "hello")

public String hello(@WebParam(name = "name") String name,
@WebParam(name = "fname") String fname,
@WebParam(name = "lname") String lname,
@WebParam(name = "location") String location,

@WebParam(name = "phone") String phone,
@WebParam(name = "credit") String credit,
@WebParam(name = "dl") String dl) {

try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
PreparedStatement st = con.prepareStatement("insert into test.student values(?,?)");
st.setString(1, name);
st.setString(2, fname);
st.setString(3, lname);
st.setString(4, location);
// int ph = Integer.parseInt(phone);
// st.setInt(5, ph);
// int cr = Integer.parseInt(credit);
// st.setInt(6, cr);
// int d1 = Integer.parseInt(dl);
// st.setInt(7, d1);

st.executeUpdate();
} catch (Exception e) {
System.out.println(e.getMessage());
}
return "record successfully entered";
}
}
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> SOA Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo