Quantcast
Channel: Spring Community Forums - Data
Viewing all articles
Browse latest Browse all 297

getSimpleJdbcTemplate().query() problem

$
0
0
Hello,

When I execute the following code, on Oracle:

Code:

public static String QUERY_DATOS_LINEA="SELECT LIN_ID,LIN_IDF FROM CVI_LINEAS@SAE_DB";

List<DatosLinea> lista = getSimpleJdbcTemplate().query(QUERY_DATOS_LINEA, new ParameterizedRowMapper<DatosLinea>(){
                        public DatosLinea mapRow(ResultSet rs, int rowNum) throws SQLException {
                                DatosLinea lin = new DatosLinea();
                                lin.setId(rs.getInt("LIN_ID"));
                                lin.setIdf(rs.getString("LIN_IDF"));
                                return lin;
                        }

I get the following error:

Exception in thread "main" org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar [SELECT LIN_ID,LIN_IDF FROM CVI_LINEAS@SAE_DB]; nested exception is java.sql.SQLSyntaxErrorException: ORA-02041: client database did not begin a transaction
ORA-02063: preceding line from SAE_DB


When I execute the query directly on TOAD, it runs ok, but with the getSimpleJdbcTemplate().query method, it doesn't work.

I know the problem is in the '@SAE_DB' part, maybe it's not compatible with this method, but that's the only way I know to access the database, since it is in another server and I can't access directly from the dblink I was given. If I don't use it, it tells me that the table CVI_LINEAS does not exist.

Anyone can help? If you need more info, just ask.

PS: sorry for the lack of details, but I'm not used to work with Oracle

Viewing all articles
Browse latest Browse all 297

Trending Articles