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"))); } }
How to Search tables in DB2
SELECT
TBNAME,
NAME,
TBCREATOR,
COLTYPE,
NULLS,
LENGTH,
SCALE
FROM SYSIBM.SYSCOLUMNS
WHERE
TBCREATOR = 'MYSCHEMA'
order by TBNAME
JRI
In Mac:
.Install R
.install.packages(“rJava”)
Create Java Application with eclipse:
import org.rosuda.JRI.REXP; import org.rosuda.JRI.Rengine; public class JavaToR { public static void main(String[] args) { System.out.println("Hello"); // Start R session. Rengine re = new Rengine (new String [] {"--vanilla"}, false, null); // Check if the session is working. if (!re.waitForR()) { return; } re.assign("x", new double[] {1.5, 2.5, 3.5}); REXP result = re.eval("(sum(x))"); System.out.println(result.asDouble()); re.end(); } }
Run application config:
VM arguments: -Djava.library.path=/Library/Frameworks/R.framework/Resources/library/rJava/jri/
Environment variable: R_HOME: /Library/Frameworks/R.framework/Resources
More linkes:
1. https://stackoverflow.com/questions/4894002/question-about-jri-error
2. https://bioincloud.wordpress.com/2015/04/02/jri-javar-problem-java-lang-unsatisfiedlinkerror-no-jri-in-java-library-path/
3. https://autofei.wordpress.com/2010/08/04/getting-rjavajri-to-work-it-is-painful/
4. http://www.studytrails.com/r/r-and-java-jri-using-eclipse/
Export mysql database
>mysqldump -u xxx -p mydb > mydb.sql
UNABLE_TO_GET_ISSUER_CERT_LOCALLY
npm ERR! code UNABLE_TO_GET_ISSUER_CERT_LOCALLY
https://stackoverflow.com/questions/45884752/npm-err-code-unable-to-get-issuer-cert-locally
npm config set registry http://registry.npmjs.org/
Fix hard disk issue
1. check the bad blocks with this command:
sudo badblocks -svw -f -c 65535 -b 4096 /dev/sda > badblocks.txt
2. Mark the badblock as un-writable
sudo e2fsck -l badblocks.txt /dev/sda