私は取得しています
org.springframework.jdbc.BadSqlGrammarException:PreparedStatementCallback; 不正なSQL文法[臨床医からcid、clinician-code、password、first-name、last-nameを選択します。ここでclinician-code =?]; ネストされた例外はcom.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorExceptionです:「フィールドリスト」の不明な列「臨床医」
次のコードでエラーが発生しました。他のすべての属性がVARCHAR(45)であるcidを除いて、スクリーンショットで表を確認することもできます。
行マッパークラス
public class CClinicianRowMapper implements RowMapper {
@Override
public Object mapRow(ResultSet rs, int line) throws SQLException {
CClinicianResultSetExtractor extractor = new CClinicianResultSetExtractor();
return extractor.extractData(rs);
}
}
ResultExtractorクラスpublicclassCClinicianResultSetExtractorはResultSetExtractorを実装します{
@Override
public Object extractData(ResultSet rs) throws SQLException {
CClinician clinician = new CClinician();
clinician.setCid(rs.getLong("cid"));
clinician.setClinicianCode(rs.getString("clinician-code"));
clinician.setPassword(rs.getString("password"));
clinician.setFirstName(rs.getString("first-name"));
return clinician;
}
}
テーブルからデータを選択するためのクラス
public List<CClinician> findClinician(CClinician _clinician) {
// TODO Auto-generated method stub
JdbcTemplate select = new JdbcTemplate(dataSource);
try
{
return select.query("select cid, clinician-code, password, first-name, last-name from Clinician where clinician-code= ?",
new Object[] {_clinician.getClinicianCode()}, new CClinicianRowMapper());
}
catch (Exception e)
{
e.printStackTrace();
}
return null;
}