当我运行此查询时:
select character from tbl_Unknown where format(fw,'.###')='48.143' and code='0001'
它在 Access 查询界面中返回结果,但是当我尝试从 Java 运行它时,它不返回结果。
我的表(tbl_Unknown):
char_id: autonumber value:1
fw: short text value:'48.1425' Hint:after format it become '48.143'.
code: short text value:'0001'
character: short text value: 'x'
我的java代码:
public static String getLostedCharacter(String font,String fw, String code) {
Connection conn = ConnectDB.getConnection();
String character = null;
try {
Statement statement = conn.createStatement();
String query = "select character from tbl_"+font+" where format(fw,'.###')='"+fw+"' and code='" + code + "'";
ResultSet rs = statement.executeQuery(query);
while (rs.next()) {
character = rs.getString(1);
return character;
}
statement.close();
rs.close();
} catch (SQLException ex) {
return "";
}
return "";
}