zoukankan      html  css  js  c++  java
  • 20165212第七周学习总结

    20165212-《Java程序设计基础》第七周学习总结

    教材学习内容总结

    • JDBC
      • 连接MySQL数据库
      • 下载JDBC-MySQL数据库驱动
      • 加载JDBC-MySQL数据库驱动
    • 连接数据库

      • (Connection getConnection(java.lang.String,java.lang.String,java.lang.String)和 Connection getConnection(java.lang.String))
      • 数据库有汉字,建立连接时要额外多传递一个参数characterEncoding
    • 查询操作

      • 建立连接得到查询对象
      • 对数据库的内容进行匹配处理
      • 关闭
    • 顺序查询:
      • 指ResultSet对象一次只能看到一个数据行,使用next()方法移到下一个数据行,next()方法最初的查询位置,即游标位置,位于第一行的前面
    • 更新、添加与删除操作
    • 通配符的使用
      • 使用预处理语句
    • 通用查询
    • 事务
      • JDBC事务的处理方式
    • 数据库的链接

    代码调试中的问题和解决过程

    • 资源里MySQL链接不可用,我上网下载XAMPP for windows,运行了教程代码
    • Ubuntu里太难弄半天没弄好,我直接在idea里弄出来了..

    代码托管:

    码云链接:https://gitee.com/BESTI-IS-JAVA-2018/20165212RenYin/tree/master/20165212

    ....教材代码我全部是copy到Ubuntu上的,没用idea跑,所以用idea做了一下第三章的课后练习

    • 1.选项:cd

      import java.util.*;
              import java.util.ArrayList;
              public class Exercise9411 {
                  public static void main(String[] args) {
                      foreach(new HashSet());
                      foreach(new ArrayList());
                  }
                  private static void foreach(Collection ##  ##elements) {
                      for(Object o : elements) {
              
                      }
                  }
              }

      分析:

     

     

     

    • 2.选项 :A

      import java.util.*;
      //import java.util.ArrayList;
      
      public class Exercise9412 {
          public static void main(String[] args) {
              foreach(new HashSet() {
              });
          }
          private static void foreach(Iterable iterable) {
              for(Object o : iterable) {
      
              }
          }
      }

      分析: 

    • 3.选项:C

      import java.util.*;
              public class Exercise9413 {
                  public static void main(String[] args) {
                      foreach(new HashSet());
                  }
                  private static void foreach(Collection collection) {
                      Iterator elements = collection.iterator();
                      while(elements.hasNext()) {
                          System.out.println(elements.next());
                      }
                  } 
              }

      分析:

    •  

    •  

    • 4.选项:D

      import java.util.*;
      class Student5212 {
          String number;
          String name;
          int score;
          Student5212(String number, String name, int score) {
              this.number = number;
              this.name = name;
              this.score = score;
          }
      }
      public class Exercise5212 {
          public static void main(String[] args) {
              Set<Student5212> students = new TreeSet<>();
              students.add(new Student5212("B1234", "Justin", 90));
              students.add(new Student5212("B5678", "Monica", 100));
              foreach(students);
          }
          private static void foreach(Collection<Student5212> students) {
              for(Student5212 student : students) {
              System.out.println(student.score);
          }
          }
      }
      

        

      分析:

    • 5。选项:D

      import java.util.*;
      class Student123 {
          String number;
          String name;
          int score;
          Student123(String number, String name, int score) {
              this.number = number;
              this.name = name;
              this.score = score;
          }
      }
      public class Exercise123 {
          public static void main(String[] args) {
              Set<Student123> students = new HashSet<>();
              students.add(new Student123("B1234", "Justin", 90));
              students.add(new Student123("B5678", "Monica", 100));
              students.add(new Student123("B1234", "Justin", 100));
              students.add(new Student123("B5678", "Monica", 98));
              students.add(new Student123("B5678", "Monica", 100));
              System.out.println(students.size());
          }
      }

    • 6.选项:A

       import java.util.*;
      public class Exercise122 {
          public static void main(String[] args) {
              Set<Integer> numbers = new TreeSet<>();
              numbers.add(1);
              numbers.add(2);
              numbers.add(1);
              numbers.add(3);
              foreach(numbers);
          }
          private static void foreach(Collection<Integer> numbers) {
              for(Integer number : numbers) {
                  System.out.println(number);
              } 
          }
      }
    • 7.选项:abc
    • 8.选项C

      import java.util.*;
      public class Exercise111 {
          public static void main(String[] args) {
              Set numbers = new TreeSet();
              numbers.add(1);
              numbers.add(2);
              numbers.add(1);
              numbers.add(3);
              for(Integer number : numbers) {
                  System.out.println(number);
              }
          }
      }

    • 9.选项:C

       import java.util.*;
      public class Exercise9987 {
          public static void main(String[] args) {
              Set<Integer> numbers = new TreeSet<>();
              numbers.add(1);
              numbers.add(2);
              numbers.add(1);
              numbers.add(3);
              for(Integer number : numbers) {
                  System.out.println(number);
              }
          }
      }

    • 10.选项:CD

       import java.util.*;
      public class Exercise110 {
          public static void main(String[] args) {
              Map<String, String> messages = new HashMap<>();
              messages.put("Justin", "Hello");
              messages.put("Monica", "HiHi");
              foreach(messages.values());
          }
          private static void foreach(Iterable<String> values) {
              for(String value : values) {
                  System.out.println(value);
              }
          }
      }

    感想:IEDA是个好东西,可是快到期了,当初脱壳...电脑还给整崩了。用ieda跑亲眼看到那些错误提示,很有感觉,自己手动敲一遍的东西印象深很多——知道怎么错的,有些东西不仅要能正确调试,知道错因也很重要。之前教材内容学的比较水,以后我会挨个用ieda练习每一章练习题夯实基础..

  • 相关阅读:
    AVA 源码解读-规则逻辑
    gojs 如何实现虚线(蚂蚁线)动画?
    谷歌复制接口json
    vue拼图动画Demo
    如何获取一个类的全名
    `webpack-dev-server --inline --progress --config build/webpack.dev.conf.js(vue报错)
    Jquery通知组件
    字典树 (Trie Tree)
    [CPP] 虚函数与纯虚函数
    格雷码
  • 原文地址:https://www.cnblogs.com/FenixRen/p/8849705.html
Copyright © 2011-2022 走看看