Advertisement
Advertisement
| 09.08.2008 at 02:53PM PDT, ID: 23713695 | Points: 500 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org;
import com.sun.xml.ws.wsdl.writer.document.soap.SOAPFault;
import javax.jws.WebMethod;
import javax.jws.WebService;
import java.sql.*;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.ws.BindingType;
import org.apache.jasper.tagplugins.jstl.core.Catch;
/**
*
* @author Administrator
*/
@WebService()
@BindingType(value = "http://java.sun.com/xml/ns/jaxws/2003/05/soap/bindings/HTTP/")
public class getWorkPackageStatusesWS {
private Connection _myCon = null;
/**
* Web service operation
*/
@WebMethod(operationName = "returnStatuses")
public String returnStatuses() throws SQLException {
Statement stmt = null;
ResultSet rs = null;
String returnString = "<results>";
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String connectionUrl = "jdbc:sqlserver://XX.X.X.XXX:1433;" +
"databaseName=SampleDB;user=user;password=pass;";
_myCon = DriverManager.getConnection(connectionUrl);
// Create and execute an SQL statement that returns some data.
String SQL = "{call dbo.spr_GetWorkPackageStatuses}";
stmt = _myCon.createStatement();
rs = stmt.executeQuery(SQL);
// Iterate through the data in the result set and display it.
while (rs.next()) {
//System.out.println(rs.getString("ID") + ": " + rs.getString("Name"));
returnString += "<param>" + "<id>" + rs.getString("ID") + "</id>" + "<name>" + rs.getString("Name") + "</name>" + "</param>";
}
//con.close();
_myCon.close();
returnString += "</results>";
return returnString;
}
catch (SQLException e) {
//System.out.println("SQL Exception: "+ e.toString());
return e.toString();
}
catch (ClassNotFoundException cE) {
//System.out.println("Class Not Found Exception: "+ cE.toString());
return cE.toString();
}
//return null;
}
}
|