Rserve in linux

/usr/local/lib/R/site-library/Rserve/java# ls -la
total 72
drwxrwxr-x 2 root staff 4096 Nov 2 14:26 .
drwxrwxr-x 8 root staff 4096 Nov 2 14:26 ..
-rw-rw-r– 1 root staff 32348 Nov 2 14:26 REngine.jar
-rw-rw-r– 1 root staff 29772 Nov 2 14:26 Rserve.jar

added in bashrc
export CLASSPATH=$CLASSPATH:/usr/local/lib/R/site-library/Rserve/java/REngine.jar:/usr/local/lib/R/site-library/Rserve/java/Rserve.jar

Read More

Spring jdbcTemplate query using Lambda

public class Employee
{
	private int id;
	private String name;
	private double salary;

	public int getId()
	{
		return id;
	}

	public void setId(int id)
	{
		this.id = id;
	}

	public String getName()
	{
		return name;
	}

	public void setName(String name)
	{
		this.name = name;
	}

	public double getSalary()
	{
		return salary;
	}

	public void setSalary(double salary)
	{
		this.salary = salary;
	}

	public Employee(int id, String name, double salary) {
		super();
		this.id = id;
		this.name = name;
		this.salary = salary;
	}

	@Override
	public String toString()
	{
		return "Employee [id=" + id + ", name=" + name + ", salary=" + salary + ", getId()=" + getId() + ", getName()="
				+ getName() + ", getSalary()=" + getSalary() + ", getClass()=" + getClass() + ", hashCode()="
				+ hashCode() + ", toString()=" + super.toString() + "]";
	}

}


import java.util.List;
import javax.sql.DataSource;
import org.springframework.jdbc.core.JdbcTemplate;

public class EmployeeDao
{

	private final JdbcTemplate jdbcTemplate;

	public EmployeeDao(DataSource dataSource) {
		this.jdbcTemplate = new JdbcTemplate(dataSource);
	}

	public List<Employee> findEmployes()
	{

		return jdbcTemplate.query("select id,name ,salary from Employee", new Object[] {},
				(rs, rowNum) -> new Employee(rs.getInt("id"), rs.getString("name"), rs.getDouble("salary")));
	}
}

Read More