Пишу сервис работающий с помощью soap пакетов,
Сервис должен возвращать баланс договора по его названию.
Написал такое в еклипсе(работает):
Код:
package api.ru.customservice.bgbilling.service.impl;
import java.sql.Connection;
import java.sql.DriverManager;
import java.util.Calendar;
import java.util.Date;
import javax.jws.WebService;
import bitel.billing.server.contract.bean.ContractManager;
import bitel.billing.server.contract.bean.BalanceUtils;
import ru.bitel.bgbilling.kernel.container.service.server.AbstractService;
import bitel.billing.server.contract.bean.ContractManager;
import bitel.billing.server.tariff.*;
@WebService(targetNamespace = "customservice")
public class MonitorServiceImpl extends AbstractService
{
public double getCurrClientBalance(String client_title)
{
double curBalance = 0.0;
Connection conn = null;
String url = "jdbc:mysql://10.5.0.3:3306/";
String dbName = "bgbilling";
String userName = "root";
String password = "root";
try
{
conn = DriverManager.getConnection(url + dbName,userName,password);
ContractManager cm = new ContractManager(conn);
BalanceUtils contr_balabce = new BalanceUtils(conn);
Date date = new Date();
curBalance = contr_balabce.getBalance(date, cm.getContractByTitle(client_title).getId()).doubleValue();;
conn.close();
return curBalance;
} catch (Exception e)
{
e.printStackTrace();
return -1.0;
}
}
}
Как получить connection к базе в самом bgbilling? И можно ли вообще?