1. 程式人生 > >List array = new ArrayList();array.add("人民銀行$$$$$");

List array = new ArrayList();array.add("人民銀行$$$$$");

 public class JDBCDemo{
     public static void main(String[] args){
     
		Class.froName("com.mysql.jdbc.Driver"); //載入驅動
		
		Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306","root","123"); //建立連線
		
    	Statement st = connection.createStatement(); //得到執行SQL語句的物件Statement

	  	ResultSet rs = st.executeQuery("select * from emp"); //執行SQL語句,返回結果集
	  	
	 	 while(){ //處理結果集
   		 		Object object = rs.getObject(2);
   				System.out.println(object);
				}

				rs.close();
				st.close();
				connection.close();
				rs = null;
				st = null;
				connection = null;
	}
}