Spring NamedParameterJdbcTemplate return empty list for oracle db

Refresh

April 2019

Views

240 time

1

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

Locale.setDefault(Locale.ENGLISH);

to my DAO class method

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

   public class StudentsDao {
    private NamedParameterJdbcTemplate namedParameterJdbcTemplate;

    @Autowired
    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(){
        Locale.setDefault(Locale.ENGLISH);
        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.

AKS

0 answers