//实现读取数据库中某一个数据的全部信息。
  public static Employee login(String name,String pwd){
  Employee employee = null;
  Connection conn=null;
  //加载数据库驱动程序。
  try {
  Class.forName(“org.sqlite.JDBC”);
  //建立连接。
  conn = DriverManager.getConnection(“jdbc:sqlite:d:/company.db”);
  //创建preparedStatement对象,接受带参数的SQL语句。
  PreparedStatement ps = conn.prepareStatement(“select * from employee where name=? and pwd=?”);
  ps.setString(1, name);
  ps.setString(2, pwd);
  ResultSet rs = ps.executeQuery();
  while(rs.next()){
  employee = new Employee(rs.getLong(1),rs.getString(2),rs.getString(3),rs.getInt(4));
  }
  } catch (ClassNotFoundException e) {
  e.printStackTrace();
  } catch (SQLException e) {
  e.printStackTrace();
  }finally {
  if(conn!=null){
  try {
  conn.close();
  } catch (SQLException e) {
  // TODO Auto-generated catch block
  e.printStackTrace();
  }
  }
  }
  return employee;
  }
  //读取数据库中的数据的函数,
  public static List fetchData(){
  Employee employee;
  //定义一个List对象,
  List list = new ArrayList();
  //创建连接对象。
  Connection conn = null;
  try {
  //加载数据库驱动程序。
  Class.forName(“org.sqlite.JDBC”);
  //建立连接。
  conn = DriverManager.getConnection(“jdbc:sqlite:d:/company.db”);
  //建立发送SQL语句的对象,
  Statement state = conn.createStatement();
  //赋值SQL语句,把SQL语句打包成一个String类型的变量。
  String string = “Select * from employee”;
  //利用Statement对象中的函数,发送SQL语句,并得到ResultSet类的一个对象
  ResultSet set = state.executeQuery(string);
  //利用next函数和get函数,赋值到Employee对象中,并加入到列表。
  while(set.next()){
  employee = new Employee(set.getLong(1),set.getString(2),set.getString(3),set.getInt(4));
  list.add(employee);
  }
  } catch (ClassNotFoundException e) {
  e.printStackTrace();
  } catch (SQLException e) {
  e.printStackTrace();
  }finally {
  if (conn!= null) {
  try {
  //数据库连接为空时。关闭数据库连接conn.
  conn.close();
  } catch (SQLException e) {
  e.printStackTrace();
  }
  }
  }
  return list;
  }
  }