Spring NamedParameterJdbcTemplate return empty list for oracle db


April 2019


240 time


I had such problem:

"ORA-12705: Cannot access NLS data files or invalid environment"

before. After reading different solution of this issue I added string


to my DAO class method

But now it returns empty list. Code of Dao class:

   public class StudentsDao {
    private NamedParameterJdbcTemplate namedParameterJdbcTemplate;

    public StudentsDao(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
        this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;

    private static final String SELECT_ALL_STUDENTS = "SELECT Student_id, Name, Address, Info FROM Students_6_1";

    public List<Student> getAllStudents(){
        Object res = namedParameterJdbcTemplate.query(SELECT_ALL_STUDENTS, new RowMapper<Student>() {
            public Student mapRow(ResultSet resultSet, int i) throws SQLException {
                int studentId = resultSet.getInt("Student_id ");
                String studentName = resultSet.getString("Name");
                String studentAddress= resultSet.getString("Address");
                String studentInfo= resultSet.getString("Info");
                return new Student(studentId, studentName, studentAddress, studentInfo);
        return (List<Student>) res;

P.S. In oracle command line query work well.


0 answers