List array = new ArrayList();array.add("人民銀行$$$$$");
阿新 • • 發佈:2018-12-15
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; } }