Project

General

Profile

« Previous | Next » 

Revision 47708

Using database service classes to avoid exception 'Method org.postgresql.jdbc4.Jdbc4Connection.isValid(int) is not yet implemented.'. We are locked to an old jdbc driver (for hibernate?)

View differences:

ClaimDatabaseUtils.java
2 2

  
3 3
import java.util.List;
4 4

  
5
import eu.dnetlib.enabling.database.DataSourceFactory;
6
import eu.dnetlib.enabling.database.utils.JdbcTemplateFactory;
5 7
import org.springframework.beans.factory.annotation.Autowired;
6
import org.springframework.jdbc.core.JdbcTemplate;
8
import org.springframework.beans.factory.annotation.Value;
7 9
import org.springframework.stereotype.Component;
8 10

  
9 11
/**
......
15 17
public class ClaimDatabaseUtils {
16 18

  
17 19
	@Autowired
18
	JdbcTemplate claimsJdbcTemplate;
20
    private JdbcTemplateFactory claimsJdbcTemplateFactory;
21
	@Autowired
22
	private DataSourceFactory claimsDataSourceFactory;
19 23

  
24
	@Value("${dnet.openaire.claims.db.name}")
25
	private String dbName;
26

  
27

  
20 28
	public List<Claim> query(String sqlQuery){
21
		return this.claimsJdbcTemplate.query(sqlQuery,
29
		this.claimsJdbcTemplateFactory.setDataSourceFactory(claimsDataSourceFactory);
30
		return this.claimsJdbcTemplateFactory.createJdbcTemplate(dbName).query(sqlQuery,
22 31
				(rs, rowNum) -> new Claim().setSemantics(rs.getString("semantics"))
23 32
						.setSource(rs.getString("source_id")).setSourceType(rs.getString("source_type"))
24 33
						.setTarget(rs.getString("target_id")).setTargetType(rs.getString("target_type")));

Also available in: Unified diff