我想從我的數據庫中選擇數據,而不是獲得某個字段,我得到「」。 我的表名是位置,它看起來像這樣:從MySQL數據庫中選擇一條記錄
id - int, location - varchar和time - timestamp。
我想選擇基於時間的最後位置,這裏是我的代碼:
this.select = this.conn.createStatement();
ResultSet result = select.executeQuery("SELECT location FROM locations ORDER BY time DESC Limit 1");
result.next();
System.out.println(result.getString(1));
我提醒你的輸出是「」;
如果選擇多行多您能得到什麼?如果通過mysql客戶端運行select,會怎麼樣? – Ilion
你試過result.getString(「location」)嗎? – travega
@travega謝謝!發佈它作爲答案。 –