Hello, I created a web service to access oracle database. This is my code:
package mypack;
import java.util.List;
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import java.sql.*;
import java.util.ArrayList;
@WebService()
public class AutoRepairWS {
@WebMethod
public List getCustomerId(@WebParam(name = "Cust_Id") String Cust_Id){
String user = "****";
String password = "****";
String url = "jdbc:oracle:thin:***:1521:xe";
String OracleDriver = "oracle.jdbc.OracleDriver";
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
List value = new ArrayList();
try{
conn = DriverManager.getConnection(url, user, password);
pstmt = conn.prepareStatement("select Cust_fname from Customers where Cust_Id = '" + Cust_Id + " '");
pstmt.setString(1, Cust_Id);
rs = pstmt.executeQuery();
while(rs.next()){
value.add(rs.getString("Cust_fname"));
}
}catch(SQLException e){
e.printStackTrace();
}
return value;
}
}
The problem is that it's supposed to return the value of Cust_fname, but i'm getting following message when I test web service:
java.util.List : "[]"
Can you help to make my program! Thanks in advance!