import java.sql.*;
public class Shuju{
public static void main(String[] args){
try{
Connection con=null;
Statement st=null;
ResultSet rs=null;
//JIA ZAI
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:students";
con=DriverManager.getConnection(url);
st=con.createStatement();
String sqlst="select sno,name,birthday,department"+" from students where sex='m'";
rs=st.executeQuery(sqlst);
System.out.println("----------chaxunbiao----------");
System.out.println("");
System.out.println("xuehao-xinmin-chshrq--yuanxi--");
while(rs.next()){
String sno=rs.getString("sno");
String name=rs.getString("name");
Date birthday=rs.getDate("birthday");
String department=rs.getString("department");
System.out.println(sno+" "+name+" ");
System.out.println(birthday+" "+department);
}
}catch(Exception e){
System.out.println(e);
}
}
}
只好请教版主了