Advertisement
Guest User

Untitled

a guest
Feb 18th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. public static void main(String[] args) {
  2. SingleConnectionDataSource ds = new SingleConnectionDataSource();
  3. ds.setDriverClassName("com.mysql.jdbc.Driver");
  4. ds.setUrl("jdbc:mysql://localhost:3306/file_storage");
  5. ds.setUsername("root");
  6. ds.setPassword("");
  7. JdbcTemplate jt = new JdbcTemplate(ds);
  8. Object o = jt.queryForObject(
  9. "select * from files where file_name=? and user_id=?", new Object[] {
  10. "xaxabbbbmn234", 2 }, new BeanPropertyRowMapper<FileData>(
  11. FileData.class));
  12. System.out.println(o);
  13. ds.destroy();
  14. }
  15.  
  16. FileData [id=124, name=null, path=null, fakePath=null, userId=2]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement