私はJavaの初心者です。問題は、Currency_nameとrateの2つの列を含むcurrencyというMySQLデータベーステーブルに通貨レートを挿入しようとしていることです。プログラムはfinanceyahooAPIから為替レートを取得しますが、データベースにデータを保存するという問題に直面しています。
void checkRateAllAtEnd() throws Exception {
/** print message */
System.out.println("checkRateAllAtEnd :");
long start = System.nanoTime();
List<Callable<HashMap>> tasks = new ArrayList<Callable<HashMap>>();
for (final String ccy : CURRENCY) {
tasks.add(new Callable<HashMap>() {
public HashMap call() throws Exception {
return getRates(ccy);
}
});
}
ExecutorService executorPool = Executors.newCachedThreadPool();
final List<Future<HashMap>> listRates = executorPool.invokeAll(tasks, 3600, TimeUnit.SECONDS);
for (Future<HashMap> rate : listRates) {
HashMap ccyRate = rate.get();
System.out.println("Value of £1 in " + ccyRate.get("CCY") + " is " + ccyRate.get("RATE"));
}
ハッシュマップからpreparedStatementに値を渡すためのクレジットが不足しています。
String sql="update currency set currency_name='"+Value1+"'";
preparedstatement=connection.prepareStatement(sql);
preparedstatement.execute();
私はこのリンクのクラス全体が完全に機能して質問をきれいに保つようにしています>> linke <<<
これは私がMYSQLに保存したいプログラムの出力です理想的には私は保存したいです
ccyRate.get( "CCY")およびccyRate.get( "RATE")
checkRateAllAtEnd :
Value of £1 in AED is 5.9201
Value of £1 in AFN is 82.4359
Value of £1 in ALL is 171.681
Value of £1 in AMD is 650.4296
Value of £1 in ANG is 2.8849
Value of £1 in AOA is 154.4766
Value of £1 in ARS is 7.9438
Value of £1 in AUD is 1.5345