Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package it.codegen;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.sql.Statement;
- import java.util.ArrayList;
- public class Test
- {
- static ArrayList<String> alist=new ArrayList<String>();
- public static void main( String[] args )
- {
- Connection hrmsCon=null;
- ResultSet rs=null;
- try
- {
- Class.forName( "com.mysql.jdbc.Driver" ).newInstance();
- hrmsCon = DriverManager.getConnection( "jdbc:mysql://192.168.0.42:3306/cgtask_qa", "cgtask_qa", "cgtask_qa" );
- Statement st = hrmsCon.createStatement();
- rs = st.executeQuery( "SELECT email FROM tsk_user" );
- while ( rs.next() )
- {
- alist.add( rs.getString( "email" ).trim() );
- }
- if(alist.contains( "yoshan@codegen.net" )){
- System.out.println("yes");
- }
- }
- catch ( InstantiationException e )
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- catch ( IllegalAccessException e )
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- catch ( ClassNotFoundException e )
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- catch ( SQLException e )
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
Add Comment
Please, Sign In to add comment