strong textI'm trying to write an application that gets the exchange rate and writes it to the database. The application reads the rate, date, id without any problems, however, it also wants the application to save what type of currency it is, when it comes to one currency, it works without problems, but the problem arises when, for example, I want to add two currencies (for example usd and eur) then I would have to duplicate the method (below the code) and converting usd to euro, however, if I wanted to download 50 currencies, duplicating the code and replacing one line is pointless, could someone advise me on how I could solve this problem because I have no idea how to deal with it without duplicating the code.
in short: I want to insert a universal value (any other currency) instead of 'usd', thanks to which I will not have to write such 50 methods for every other currency.
public static void actionPerformed(double rateValue) {
try {
pst = con.prepareStatement("insert into course(val,cur)values(?,'usd')");
pst.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}
}
Aucun commentaire:
Enregistrer un commentaire