Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package sample.controller;
- import javafx.application.Platform;
- import javafx.beans.value.ObservableValue;
- import javafx.collections.FXCollections;
- import javafx.collections.ObservableList;
- import javafx.fxml.FXML;
- import javafx.fxml.FXMLLoader;
- import javafx.fxml.Initializable;
- import javafx.print.PageOrientation;
- import javafx.print.Paper;
- import javafx.print.Printer;
- import javafx.print.PrinterJob;
- import javafx.scene.Parent;
- import javafx.scene.Scene;
- import javafx.scene.control.Alert;
- import javafx.scene.control.Alert.AlertType;
- import javafx.scene.control.Button;
- import javafx.scene.control.ButtonType;
- import javafx.scene.control.ComboBox;
- import javafx.scene.control.TableColumn;
- import javafx.scene.control.TableView;
- import javafx.scene.control.cell.PropertyValueFactory;
- import javafx.stage.FileChooser;
- import javafx.stage.Stage;
- import javafx.stage.StageStyle;
- import javafx.stage.Window;
- import net.sf.jasperreports.engine.JRException;
- //import net.sf.jasperreports.engine.JRException;
- //import net.sf.jasperreports.engine.JasperRunManager;
- import net.sf.jasperreports.engine.JasperRunManager;
- import org.codehaus.jackson.JsonFactory;
- import org.codehaus.jackson.JsonParser;
- import org.codehaus.jackson.JsonToken;
- import sample.BackStack;
- import sample.Main;
- import sample.connection.Connector;
- import sample.model.*;
- import sample.model.Currency;
- import java.awt.Desktop;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import java.io.InputStream;
- import java.io.OutputStream;
- import java.net.URL;
- import java.net.URLDecoder;
- import java.sql.*;
- import java.text.DecimalFormat;
- import java.util.*;
- /**
- * Autor Filip
- */
- public class CalculationsController implements Initializable {
- @FXML
- public TableView<Calculation> tvCalculation;
- @FXML
- public ComboBox cbCurrency;
- @FXML
- Button btnPrintData;
- private ObservableList<String> currencyList;
- private ObservableList<Calculation> calculationList;
- private ObservableList<CurrencyRates> ratesList;
- static List<Country> countryList;
- private Connection connection;
- private Statement statement;
- private ResultSet set;
- private ObservableList<CalculationHelper> helperList;
- Window owner;
- @Override
- public void initialize(URL location, ResourceBundle resources) {
- try {
- ratesList = fetchCurrencyListValue();
- setTable();
- setValuesForTable();
- fetchCountrys();
- } catch (IOException e) {
- e.printStackTrace();
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- public CalculationsController() throws SQLException {
- currencyList = FXCollections.observableArrayList();
- calculationList = FXCollections.observableArrayList();
- ratesList = FXCollections.observableArrayList();
- connection = Connector.getConnection();
- helperList = FXCollections.observableArrayList();
- countryList = new ArrayList<>();
- statement = connection.createStatement();
- }
- /**
- * Povlacenje kursne liste pomocu API-a Narodne Banke Srbije
- *
- * @return kursna lista
- * @throws IOException
- */
- public ObservableList<CurrencyRates> fetchCurrencyListValue() throws IOException {
- ObservableList<CurrencyRates> list = FXCollections.observableArrayList();
- String url = "https://kurs.resenje.org/api/v1/rates/today";
- JsonFactory f = new JsonFactory();
- JsonParser jp = f.createJsonParser(new URL(url));
- JsonToken token = jp.nextToken();
- while (token != jp.nextToken().START_ARRAY) {
- token = jp.nextToken();
- }
- while (token != JsonToken.END_ARRAY) {
- token = jp.nextToken();
- if (token == JsonToken.START_OBJECT) {
- CurrencyRates currencyRates = parseRates(jp);
- list.add(currencyRates);
- }
- }
- int x = 0;
- for (CurrencyRates currencyRates : list) {
- System.out.println(x++);
- System.out.println("Valuta: " + currencyRates.getCode() + " Dnevni srednji kurs: "
- + currencyRates.getExchange_middle());
- }
- return list;
- }
- /**
- * Vraca jedan objetak Valute (ime, kurs pre dinaru)
- *
- * @param jp
- * @return
- * @throws IOException
- */
- public CurrencyRates parseRates(JsonParser jp) throws IOException {
- CurrencyRates currencyRates = new CurrencyRates();
- JsonToken token = jp.nextToken();
- while (token != JsonToken.END_OBJECT) {
- if (token == JsonToken.END_OBJECT) {
- while (token != JsonToken.END_OBJECT) {
- token = jp.nextToken();
- }
- }
- if (token == JsonToken.FIELD_NAME) {
- String currentName = jp.getCurrentName();
- if ("code".equals(currentName)) {
- jp.nextToken();
- currencyRates.setCode(jp.getText());
- }
- if ("exchange_middle".equals(currentName)) {
- jp.nextToken();
- currencyRates.setExchange_middle(jp.getDoubleValue());
- }
- }
- token = jp.nextToken();
- }
- return currencyRates;
- }
- /**
- * Setovanje kolona tabele
- */
- public void setTable() {
- TableColumn nameCol = new TableColumn(" ");
- nameCol.setMinWidth(100);
- nameCol.setCellValueFactory(new PropertyValueFactory<Costs, String>("name"));
- nameCol.setSortable(false);
- TableColumn valueCol = new TableColumn("Iznos");
- valueCol.setMinWidth(100);
- valueCol.setCellValueFactory(new PropertyValueFactory<Costs, String>("value"));
- valueCol.setSortable(false);
- TableColumn currencyCol = new TableColumn("Valuta");
- currencyCol.setMinWidth(100);
- currencyCol.setCellValueFactory(new PropertyValueFactory<Costs, String>("currency"));
- currencyCol.setSortable(false);
- TableColumn rateCol = new TableColumn("Kurs ");
- rateCol.setMinWidth(100);
- rateCol.setCellValueFactory(new PropertyValueFactory<Costs, String>("rate"));
- rateCol.setSortable(false);
- TableColumn valueRDSCol = new TableColumn("Dinarska vrednost");
- valueRDSCol.setMinWidth(150);
- valueRDSCol.setCellValueFactory(new PropertyValueFactory<Costs, String>("valueRDS"));
- valueRDSCol.setSortable(false);
- tvCalculation.getColumns().addAll(nameCol, valueCol, currencyCol, rateCol, valueRDSCol);
- // setValuesForTable("EUR");
- }
- /**
- * Na osnovu troskova, unetih akontacije vrsi se racunanje i prikazivanje
- * dobijenih vrednosti u tabelu Kada korisnik odabere iz padajuceg menija valutu
- * u tabeli se prikazuju svi troskovi, akontacije za tu valutu
- *
- * @param
- */
- public void setValuesForTable() {
- calculationList.clear();
- List<String> currencys = new ArrayList<>();
- for (Currency currency : AdvancePaymentController.currencieList) {
- currencys.add(currency.getNameCurrency());
- }
- ObservableList<Costs> costsList = TravelCostsController.costsObservableList;
- ObservableList<AdvensedPayments> list = AdvancePaymentController.advensedPaymentsObservableList;
- Collections.sort(costsList, new Costs.SortByCostName());
- for (AdvensedPayments advensedPayments : list) {
- double rate = returnRate(advensedPayments.getCurrencyName());
- Calculation calculation = new Calculation("Akontacija", advensedPayments.getValue(),
- advensedPayments.getCurrencyName(), rate,
- Double.parseDouble(new DecimalFormat(".##").format(rate * advensedPayments.getValue())));
- calculationList.add(calculation);
- if (checkFinalCurrencyCalculation(advensedPayments.getCurrencyName())) {
- CalculationHelper helper = new CalculationHelper(advensedPayments.getCurrencyName(),
- advensedPayments.getValue(), 0);
- helperList.add(helper);
- } else {
- for (CalculationHelper calculationHelper : helperList) {
- if (calculationHelper.getCurrencyName().equals(advensedPayments.getCurrencyName())) {
- calculationHelper.setTotalAdvencedPayment(
- calculationHelper.getTotalAdvencedPayment() + advensedPayments.getValue());
- }
- }
- }
- }
- //
- for (Costs costs : costsList) {
- double rate = returnRate(costs.getCurrency());
- Calculation calculation = new Calculation(costs.getCostTypeName(), costs.getCostValue(),
- costs.getCurrency(), rate,
- Double.parseDouble(new DecimalFormat(".##").format(rate * costs.getCostValue())));
- calculationList.add(calculation);
- if (!currencys.contains(costs.getCurrency())) {
- if (checkFinalCurrencyCalculation("EUR")) {
- CalculationHelper calculationHelper = new CalculationHelper("EUR", 0,
- Double.parseDouble(new DecimalFormat(".##").format(
- costs.getCostValue() / (returnRate("EUR") / returnRate(costs.getCurrency())))));
- helperList.add(calculationHelper);
- } else {
- for (CalculationHelper calculationHelper : helperList) {
- if (calculationHelper.getCurrencyName().equals("EUR")) {
- calculationHelper.setTotalCosts(calculationHelper.getTotalCosts()
- + costs.getCostValue() / (returnRate("EUR") / returnRate(costs.getCurrency())));
- }
- }
- }
- } else {
- System.out.println("STVARNO NEMA LOGIKE: " + costs.getCurrency() + " " + costs.getCostValue());
- if (checkFinalCurrencyCalculation(costs.getCurrency())) {
- CalculationHelper helper = new CalculationHelper(costs.getCurrency(), 0, costs.getCostValue());
- helperList.add(helper);
- } else {
- for (CalculationHelper calculationHelper : helperList) {
- if (calculationHelper.getCurrencyName().equals(costs.getCurrency())) {
- calculationHelper.setTotalCosts(calculationHelper.getTotalCosts() + costs.getCostValue());
- }
- }
- }
- }
- }
- // public Calculation(String name, double value, String currency, double rate,
- // double valueRDS) {
- for (CalculationHelper calculationHelper : helperList) {
- double rate = returnRate(calculationHelper.getCurrencyName());
- Calculation calculation = new Calculation("Ukupan trosak",
- Double.parseDouble(new DecimalFormat(".##").format(calculationHelper.getTotalCosts())),
- calculationHelper.getCurrencyName(), rate,
- Double.parseDouble(new DecimalFormat(".##").format(rate * calculationHelper.getTotalCosts())));
- calculationList.add(calculation);
- if (calculationHelper.getTotalCosts() > calculationHelper.getTotalAdvencedPayment()) {
- Calculation calculation1 = new Calculation("Isplata zaposlenom",
- Double.parseDouble(new DecimalFormat(".##").format(
- calculationHelper.getTotalCosts() - calculationHelper.getTotalAdvencedPayment())),
- calculationHelper.getCurrencyName(), rate,
- Double.parseDouble(new DecimalFormat(".##").format(rate
- * (calculationHelper.getTotalCosts() - calculationHelper.getTotalAdvencedPayment()))));
- calculationList.add(calculation1);
- }
- if (calculationHelper.getTotalAdvencedPayment() > calculationHelper.getTotalCosts()) {
- Calculation calculation1 = new Calculation("Isplata firmi",
- Double.parseDouble(new DecimalFormat(".##").format(
- calculationHelper.getTotalAdvencedPayment() - calculationHelper.getTotalCosts())),
- calculationHelper.getCurrencyName(), rate,
- Double.parseDouble(new DecimalFormat(".##").format(rate
- * (calculationHelper.getTotalAdvencedPayment() - calculationHelper.getTotalCosts()))));
- calculationList.add(calculation1);
- }
- // System.out.println(calculationHelper.getCurrencyName()+"
- // "+calculationHelper.getTotalAdvencedPayment()+"
- // "+calculationHelper.getTotalCosts());
- }
- tvCalculation.setItems(calculationList);
- }
- /**
- * Cuvanje puta, putSvake, akontacija i troskova u bazi podataka
- *
- * @throws SQLException
- * // * @throws JRException
- * @throws IOException
- * @throws JRException
- */
- public byte[] saveToDataBase() throws SQLException /* JRException */, IOException, JRException {
- Travel travel = UserController.travel;
- // query.append("SELECT * FROM Korisnici where
- // username='").append(tfUsername.getText()).append("' ").append(
- // "and ").append("password='").append(tfPassword.getText()).append("'");
- StringBuilder query = new StringBuilder();
- query.append("INSERT INTO `Putevi` (`korisnik_id`, `datum_polaska`, `vreme_polaska`, "
- + "`datum_povratka`, `vreme_povratka`, `datum_granica_povratak`, "
- + "`vreme_granica_povratak`) VALUES (").append("'1'").append(",'").append(travel.getGoingDate())
- .append("','").append(travel.getGoingTime()).append("','").append(travel.getBackDate()).append("','")
- .append(travel.getBackTime()).append("','").append(travel.getBackBorderDate()).append("','")
- .append(travel.getBackBorderTime()).append("')");
- System.out.println(query.toString());
- int number = 0;
- PreparedStatement preparedStatement = connection.prepareStatement(String.valueOf(query),
- Statement.RETURN_GENERATED_KEYS);
- preparedStatement.executeLargeUpdate();
- ResultSet resultSet = preparedStatement.getGeneratedKeys();
- while (resultSet.next()) {
- number = resultSet.getInt(1);
- }
- for (AdvensedPayments advensedPayments : AdvancePaymentController.advensedPaymentsObservableList) {
- int currencyId = 1;
- for (Currency currency : AdvancePaymentController.currencieList) {
- if (advensedPayments.getCurrencyName().equals(currency.getNameCurrency())) {
- currencyId = currency.getIdCurrency();
- }
- }
- preparedStatement = connection.prepareStatement(
- "INSERT INTO `Akontacije` (`put_id`, `vatula_id`, `iznos`, akontacijaKurs, DinarskaVrednost) VALUES (?, ?, ?, ?, ?)");
- preparedStatement.setInt(1, number);
- preparedStatement.setInt(2, currencyId);
- preparedStatement.setDouble(3, advensedPayments.getValue());
- preparedStatement.setDouble(4, returnRate(advensedPayments.getCurrencyName()));
- preparedStatement.setDouble(5,
- returnRate(advensedPayments.getCurrencyName()) * advensedPayments.getValue());
- boolean ressult = preparedStatement.execute();
- }
- ObservableList<TravelPart> list = UserController.travelParts;
- for (TravelPart travelPart : list) {
- System.out.println(travelPart.getContryName());
- System.out.println(travelPart.getCheat());
- if (!travelPart.getCheat().equals("Prolazak")) {
- int idCountry = returnCounryId(travelPart.getContryName());
- int idStavke = 1;
- preparedStatement = connection.prepareStatement(
- "INSERT INTO PuteviStavke (put_id, zemlja_id, datum_prelaska_granice, vreme_prelaska_granice, broj_sati, broj_dnevnica)"
- + " VALUES (?, ?, ?, ?, ?, ?)",
- Statement.RETURN_GENERATED_KEYS);
- preparedStatement.setInt(1, number);
- preparedStatement.setInt(2, idCountry);
- if (travelPart.getContryName().equals("Srbija")) {
- preparedStatement.setString(3, null);
- preparedStatement.setString(4, "");
- } else {
- preparedStatement.setString(3, travelPart.getBorderDate().toString());
- preparedStatement.setString(4, travelPart.getBorderTime());
- }
- int numberHours = (int) travelPart.getNumHours();
- preparedStatement.setInt(5, numberHours);
- preparedStatement.setDouble(6, travelPart.getNumberDays());
- preparedStatement.executeUpdate();
- resultSet = preparedStatement.getGeneratedKeys();
- if (resultSet.next()) {
- idStavke = resultSet.getInt(1);
- }
- for (Costs costs : travelPart.getCostsList()) {
- System.out.println("ovo su troskovi: " + costs.getCostTypeName());
- int typeID = getCostsID(costs.getCostTypeName());
- double rate = returnRate(costs.getCurrency());
- preparedStatement = connection.prepareStatement(
- "INSERT INTO `TroskoviPutovanja` (`stavke_id`, `id_vrste`, `iznos`, `valuta`, `kurs`, `dinarska_protiv_vrednost`) "
- + "VALUES (?, ?, ?, ?, ?, ?)");
- preparedStatement.setInt(1, idStavke);
- preparedStatement.setInt(2, typeID);
- preparedStatement.setDouble(3, costs.getCostValue());
- preparedStatement.setString(4, costs.getCurrency());
- preparedStatement.setDouble(5, rate);
- preparedStatement.setDouble(6, rate * costs.getCostValue());
- preparedStatement.execute();
- }
- System.out.println(idStavke + "ovo je stavka");
- }
- }
- for (CalculationHelper calculationHelper : helperList) {
- double rate = returnRate(calculationHelper.getCurrencyName());
- preparedStatement = connection.prepareStatement(
- "INSERT INTO `Obracun` (`put_id`, `obracunIme`, `iznos`, `valuta`, `kurs`, `dinarska_vrednost`) "
- + "VALUES (?, ? , ? , ? , ? , ? )");
- preparedStatement.setInt(1, number);
- preparedStatement.setString(2, "Ukupan trosak");
- preparedStatement.setDouble(3, calculationHelper.getTotalCosts());
- preparedStatement.setString(4, calculationHelper.getCurrencyName());
- preparedStatement.setDouble(5, rate);
- preparedStatement.setDouble(6, rate * calculationHelper.getTotalCosts());
- preparedStatement.execute();
- if (calculationHelper.getTotalCosts() > calculationHelper.getTotalAdvencedPayment()) {
- preparedStatement = connection.prepareStatement(
- "INSERT INTO `Obracun` (`put_id`, `obracunIme`, `iznos`, `valuta`, `kurs`, `dinarska_vrednost`) "
- + "VALUES (?, ? , ? , ? , ? , ? )");
- preparedStatement.setInt(1, number);
- preparedStatement.setString(2, "Isplata zaposlenom");
- preparedStatement.setDouble(3,
- calculationHelper.getTotalCosts() - calculationHelper.getTotalAdvencedPayment());
- preparedStatement.setString(4, calculationHelper.getCurrencyName());
- preparedStatement.setDouble(5, rate);
- preparedStatement.setDouble(6,
- rate * (calculationHelper.getTotalCosts() - calculationHelper.getTotalAdvencedPayment()));
- preparedStatement.execute();
- }
- if (calculationHelper.getTotalAdvencedPayment() > calculationHelper.getTotalCosts()) {
- preparedStatement = connection.prepareStatement(
- "INSERT INTO `Obracun` (`put_id`, `obracunIme`, `iznos`, `valuta`, `kurs`, `dinarska_vrednost`) "
- + "VALUES (?, ? , ? , ? , ? , ? )");
- preparedStatement.setInt(1, number);
- preparedStatement.setString(2, "Isplata firmi");
- preparedStatement.setDouble(3,
- calculationHelper.getTotalAdvencedPayment() - calculationHelper.getTotalCosts());
- preparedStatement.setString(4, calculationHelper.getCurrencyName());
- preparedStatement.setDouble(5, rate);
- preparedStatement.setDouble(6,
- rate * (calculationHelper.getTotalAdvencedPayment() - calculationHelper.getTotalCosts()));
- preparedStatement.execute();
- }
- }
- return printReport(number);
- }
- /**
- * Vraca idZemlje za unetu zemlju
- *
- * @param countryName
- * zemlja
- * @return
- * @throws SQLException
- */
- public int returnCounryId(String countryName) throws SQLException {
- for(Country country: countryList) {
- if(country.getName().equals(countryName)){
- return country.getCountry_id();
- }
- }
- return 0;
- }
- /**
- * Vraca ID tipa troska na osnovu imena troska
- *
- * @param s
- * @return
- * @throws SQLException
- */
- public int getCostsID(String s) throws SQLException {
- int id = 1;
- // SELECT * FROM `VrsteTroskova` WHERE VrsteTroskova.id_vrste = 1
- PreparedStatement ps = connection
- .prepareStatement("SELECT * FROM `VrsteTroskova` WHERE VrsteTroskova.naziv =(?)");
- ps.setString(1, s);
- ResultSet resultSet = ps.executeQuery();
- while (resultSet.next()) {
- id = resultSet.getInt("id_vrste");
- }
- return id;
- }
- public double returnRate(String s) {
- for (CurrencyRates currencyRates : ratesList) {
- if (currencyRates.getCode().equals(s)) {
- return currencyRates.getExchange_middle();
- }
- }
- return 0;
- }
- public boolean checkFinalCurrencyCalculation(String s) {
- if (helperList.size() == 0) {
- return true;
- }
- for (CalculationHelper calculationHelper : helperList) {
- if (calculationHelper.getCurrencyName().equals(s)) {
- return false;
- }
- }
- return true;
- }
- public void onBackPressed() {
- BackStack.pop();
- }
- public byte[] printReport(int putID) throws JRException, IOException, SQLException {
- String path = Main.class.getProtectionDomain().getCodeSource().getLocation().getPath();
- System.out.println(path+"/reports/Blank_A4.jasper");
- // File reportFile = new File(path+"/reports/Blank_A4.jasper");
- InputStream jasperIS = getClass().getResourceAsStream("/reports/Blank_A4.jasper");
- Map parameters = new HashMap();
- parameters.put("putID", putID + "");
- byte[] bytes = JasperRunManager.runReportToPdf(jasperIS, parameters,
- Connector.getConnection());
- // byte[] bytes = JasperRunManager.runReportToPdf(reportFile.getPath(),
- // parameters, conn);
- OutputStream out = new FileOutputStream("izveštaj.pdf");
- out.write(bytes);
- out.close();
- return bytes;
- }
- public void restartTravel() throws SQLException, IOException {
- BackStack.cleanBackStack();
- Parent parent = FXMLLoader.load(getClass().getResource("user.fxml"));
- Stage stage = new Stage(StageStyle.DECORATED);
- stage.setTitle("Obračun poslovnih puteva - Korisnički deo");
- stage.setScene(new Scene(parent));
- BackStack.push(stage);
- stage.show();
- }
- public void saveReport(byte[] bytes) {
- System.out.println("JERI ULAZIS OVDEEEE");
- FileChooser fileChooser = new FileChooser();
- fileChooser.setTitle("Sacuvaj izvestaj na lokaciji:");
- fileChooser.setInitialFileName("izvestaj.pdf");
- FileChooser.ExtensionFilter pdfExtensionFilter = new FileChooser.ExtensionFilter(
- "PDF - Portable Document Format (.pdf)", "*.pdf");
- fileChooser.getExtensionFilters().add(pdfExtensionFilter);
- fileChooser.setSelectedExtensionFilter(pdfExtensionFilter);
- File file = fileChooser.showSaveDialog(BackStack.getLastStage());
- if (file != null) {
- try {
- writePdf(file, bytes);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
- public void writePdf(File file, byte[] bytes) throws IOException, SQLException {
- String path = Main.class.getProtectionDomain().getCodeSource().getLocation().getPath();
- System.out.println(path+"/reports/Blank_A4.jasper");
- OutputStream out = new FileOutputStream(file);
- out.write(bytes);
- out.close();
- File brisi = new File("izveštaj.pdf");
- brisi.delete();
- restartTravel();
- }
- public void openDialog() throws SQLException, IOException, JRException {
- String path = Main.class.getProtectionDomain().getCodeSource().getLocation().getPath();
- String decodedPath = URLDecoder.decode(path, "UTF-8");
- Alert alert = new Alert(AlertType.INFORMATION);
- alert.setTitle("Odaberite opciju");
- alert.setHeaderText(null);
- alert.setContentText("Odaberite opciju");
- ButtonType buttonTypeOne = new ButtonType("Novi izvestaj");
- ButtonType buttonTypeTwo = new ButtonType("Sacuvaj PDF");
- ButtonType buttonTypeThree = new ButtonType("Stampaj");
- ButtonType buttonTypeFour = new ButtonType("Izadji");
- alert.getButtonTypes().setAll(buttonTypeOne, buttonTypeTwo, buttonTypeThree, buttonTypeFour);
- Optional<ButtonType> result = alert.showAndWait();
- if (result.get() == buttonTypeOne) {
- restartTravel();
- } else if (result.get() == buttonTypeTwo) {
- saveReport(saveToDataBase());
- } else if(result.get() == buttonTypeThree) {
- saveToDataBase();
- if (Desktop.isDesktopSupported()) {
- try {
- File myFile = new File("izveštaj.pdf");
- Desktop.getDesktop().open(myFile);
- } catch (IOException ex) {
- System.out.println("Sta je ovo breeee: ");
- }
- }
- restartTravel();
- } else {
- Platform.exit();
- }
- }
- public void fetchCountrys() throws SQLException {
- String sql = "select * from Zemlje";
- set = statement.executeQuery(sql);
- while (set.next()){
- Country country = new Country(set.getInt("zemlja_id"), set.getString("naziv"), set.getInt("dnevnica"));
- countryList.add(country);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement