首页 > 其他 > 详细

20165212第七周学习总结

时间:2018-04-15 22:33:40      阅读:208      评论:0      收藏:0      [点我收藏+]

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练习每一章练习题夯实基础..

20165212第七周学习总结

原文:https://www.cnblogs.com/FenixRen/p/8849705.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!