Guest User

Untitled

a guest
Oct 26th, 2017
393
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. package it.codegen;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.ResultSet;
  6. import java.sql.SQLException;
  7. import java.sql.Statement;
  8. import java.util.ArrayList;
  9.  
  10. public class Test
  11. {
  12. static ArrayList<String> alist=new ArrayList<String>();
  13.  
  14. public static void main( String[] args )
  15. {
  16. Connection hrmsCon=null;
  17. ResultSet rs=null;
  18. try
  19. {
  20. Class.forName( "com.mysql.jdbc.Driver" ).newInstance();
  21.  
  22. hrmsCon = DriverManager.getConnection( "jdbc:mysql://192.168.0.42:3306/cgtask_qa", "cgtask_qa", "cgtask_qa" );
  23.  
  24. Statement st = hrmsCon.createStatement();
  25. rs = st.executeQuery( "SELECT email FROM tsk_user" );
  26. while ( rs.next() )
  27. {
  28. alist.add( rs.getString( "email" ).trim() );
  29. }
  30.  
  31. if(alist.contains( "yoshan@codegen.net" )){
  32. System.out.println("yes");
  33. }
  34. }
  35. catch ( InstantiationException e )
  36. {
  37. // TODO Auto-generated catch block
  38. e.printStackTrace();
  39. }
  40. catch ( IllegalAccessException e )
  41. {
  42. // TODO Auto-generated catch block
  43. e.printStackTrace();
  44. }
  45. catch ( ClassNotFoundException e )
  46. {
  47. // TODO Auto-generated catch block
  48. e.printStackTrace();
  49. }
  50. catch ( SQLException e )
  51. {
  52. // TODO Auto-generated catch block
  53. e.printStackTrace();
  54. }
  55.  
  56. }
  57.  
  58. }
Add Comment
Please, Sign In to add comment