package com.sql;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class Select {
public static void main(String[] args){
try {
Class.forName("com.mysql.jdbc.Driver");
try {
Connection ct=DriverManager.getConnection("jdbc:mysql://localhost:3306/school","root","hequnjie");
Statement st=ct.createStatement();
ResultSet rs=st.executeQuery("select*from student1 where name='何羣傑'");
while(rs.next()){
System.out.println(rs.getString(1)+rs.getString(2));
}
ct.close();
st.close();
rs.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}