Guest User

Untitled

a guest
Aug 9th, 2018
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. package com.hexaware.util;
  2.  
  3. import com.hexaware.model.*;
  4. import com.hexaware.persistence.*;
  5. import com.hexaware.mapper.*;
  6. import org.skife.jdbi.v2.DBI;
  7. import com.hexaware.persistence.*;
  8. import java.util.List;
  9.  
  10. public class JdbiClient {
  11. public static void main(String args[]){
  12. StudentDAO dao = getConnect().onDemand(StudentDAO.class);
  13. List<Student> studentList = dao.list();
  14.  
  15. for(Student student: studentList){
  16. System.out.println(student.getName());
  17. }
  18. }
  19.  
  20. public static final DBI getConnect() {
  21. try {
  22. Class.forName("com.mysql.jdbc.Driver");
  23. DBI dbi = new DBI("jdbc:mysql://localhost/training?useSSL=false", "root", "welcome");
  24. return dbi;
  25. } catch (ClassNotFoundException e) {
  26. e.printStackTrace();
  27. throw new RuntimeException(e);
  28. }
  29. }
  30. }
Add Comment
Please, Sign In to add comment