我有一個存儲過程,我想在Java中調用過程並用作Web服務。我一直在進行多個操作,「deger」返回單個值,如何返回多個值?快樂編碼如何在Java中返回多個值(插入sp)?
My procedure :
CREATE OR REPLACE PROCEDURE thkk_kaydet(
p_no IN TEMP_TAHAKKUK_AG.ABONENO%TYPE,
p_tplm IN TEMP_TAHAKKUK_AG.TOPLAM%TYPE)
IS
BEGIN
INSERT INTO TEMP_TAHAKKUK_AG ("ABONENO", "TOPLAM")
VALUES (p_no, p_tplm);
COMMIT;
END;
我的Web服務類 - 與連接方法
import javax.jws.WebService;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.jws.WebMethod;
@WebService
public class WSWebLogic {
public static Connection getConnection_test() throws Exception {
String driver = "oracle.jdbc.driver.OracleDriver";
String url = "jdbc:oracle:thin:@00.00.0.00:1521:TEST";
String username = "username";
String password = "password";
Class.forName(driver); // load Oracle driver
Connection conn = DriverManager.getConnection(url, username, password);
return conn;
}
@WebMethod
public static void get_tatil (@WebParam(name = "arg0") String p_no, int p_tplm) {
Connection conn=null;
Statement stmt=null;
ResultSet rs=null;
String deger=null;
try {
conn = getConnection_test();
String query = "BEGIN" +
"thkk_kaydet('" +
p_no +
"','" +
p_tplm +
"');" +
"END";
stmt = conn.createStatement();
rs = stmt.executeQuery(query);
while (rs.next()) {
deger = rs.getString(1);
}
} catch (Exception e) {
System.err.println(e.getMessage());
} finally {
try {
rs.close();
stmt.close();
conn.close();
} catch (SQLException e) {
System.err.println(e.getMessage());
}
}
}
}
謝謝,但我需要通過java web服務插入到oracle(p_no和p_tplm列)中,它們必須分別作爲p_no和p_tplm列。 –
返回爲JSON,解析JSON並插入其他數據庫@ M.Telceken –
我添加爲答案,你能幫我嗎? Tnx很多@Danyal Sandeelo –