20165226 2017-2018-4 "Java Programming" 7th Week study Summary

Source: Internet
Author: User
Tags java throws

20165226 2017-2018-4 "Java program Design" 7th Week study Summary Textbook Learning contents Summary 11th Chapter JDBC and MySQL Database
    • Download the latest version of MySQL.
    • Connecting to a database
      • Download Jdbc-mysql Database Driver
      • Load Jdbc-mysql Database Driver
      • Connect to Database ( Connection getConnection(java.lang.String,java.lang.String,java.lang.String) and Connection getConnection(java.lang.String) )
    • Inquire
      • Sequential query, using next() move to next data row
      • Condition and sort Query
        • where child statement
        • Sorting, order by sorting records with child statements

          select * from mess order by heightselect * from mess where name like ‘%林%‘ order by name
    • Statement Object Invocation Method
    • Updateupdate 表 set 字段 = 新值 where<条件子句>
    • Add toinsert into 表(字段列表)value (对应的具体的记录)
    • Deletedelete from 表名 where <条件子句>
    • Connecting to a SQL Server database
Problems in teaching materials learning and the solving process
    • Question one: Some doubts in learning P328 11.5 连接数据库 Why use JDB to connect to the database?
    • Problem a solution: Like an interface, want to use this interface, it is necessary to implement the method in this interface, JDBC is the same, it implements some specific functions of the interface, that is, those who can connect the database method, so you must use it. But you can also use Hibernate,ibatis without JDBC.

    • Question two: When querying the last question, I saw hibernate, wondering what the difference between Hibernate and JDBC Connection database is?
    • Problem two solution:

      1、Hibernate先检索缓存中的映射对象( 即hibernate操作的是对象),而jdbc则是直接操作数据库。2、Hibernate是JDBC的轻量级的对象封装,它是一个独立的对象持久层框架,和App Server,和EJB没有什么必然的联系。Hibernate可以用在任何JDBC可以使用的场合。3、Hibernate是一个和JDBC密切关联的框架,所以Hibernate的兼容性和JDBC驱动,和数据库都有一定的关系,但是和使用它的Java程序,和App Server没有任何关系,也不存在兼容性问题。Hibernate毕竟是基于JDBC的技术,高度的封装提高了开发效率,从运行效率上来说如果正确使用JDBC那一定是比HB高的。
Problems in code debugging and resolution of claims
    • Problem one: When compiling the example11_1, a little bit of bug appeared.

    • Problem One solution: Enter the download in Ubuntu to sudo apt-get install mysql-server mysql-client install MySQL

    • Issue two: An error occurred while uploading the code

    • Problem two solution: a bit more than that, the result is origin a spellingorigion
    • Issue three: A series of minor bugs, such as failed to initialize, occurred while downloading the MySQL client management tool.

    • Problem three solution: Start searching for related errors and solutions on the web, then write the source file save, then found another bug (see the second picture), and then back to the book, try to figure out, actually this step decompression, I actually have extracted, so I skip this link, directly mysqld install, and then the installation was successful.

    • Issue four: An error occurred while changing the password after entering the MySQL installation directory

    • Problem Four solution: originally initialized when the original user did not set the password, so directly enter , then can change the password
Code Hosting

Summary of the fifth Zhou question in the last week's exam error
  • Knowledge Points: In the class body of an inner class, you cannot declare class variables and class methods, P162 pages.

    下列关于内部类的说法,正确的是A       其他类不可以用某个类的内部类声明对象。B       内部类字节码文件的名字格式是“外嵌类名$内部类名”。C       内部类的类体可以声明类变量和类方法。D       内部类在成员位置上,因此可以被private修饰。正确答案: A B D  我的答案: A B
  • Knowledge Point: Java throws an exception using throw, and using the throws declaration method may throw an exception.

    下列关于异常的说法,错误的是A       Java使用throws抛出一个异常,使用throw声明方法可能抛出异常。B       执行System.out.println(3/0);语句会报ArithmeticException异常。C       Java中的错误是以对象的方式呈现为java.lang.Throwable的各种子类实例。D       方法parseInt()在执行过程中可能抛出DataFormatException异常。正确答案: A D  我的答案: D
  • Knowledge points: For serious errors, described by the error class, and for non-serious problems, it is described by the exception class.

    如果超出JVM运行能力之外,如“byte[] arr=new byte[1024*1024*600];”会抛出java.lang.OutOfMemoryError异常。A       trueB       false正确答案: B  我的答案: A
  • Knowledge Point: If the process is written to return first, there are finally chunks, finally the block will be executed first, and then return the value. There is only one case where the finally code block will not be executed, that is, System.exit (0) was executed previously.

    下列程序的运行结果为public class FinallyDemo {public static void main(String[] args) {   System.out.print(test(true));}static int test(boolean flag) {   try {   if (flag) {       return 1;   }   } finally {   System.out.print("finally…");   }   return 0;}}A       1finally…B       finally…1C       1finally…0D       1正确答案: B  我的答案: C
  • Knowledge point: Public int hashcode (): Computes the hash code for this abstract path name.

    以下关于File类常用方法的叙述,错误的是A       public long length():获取文件长度B       public int hashCode():计算此文件的哈希码C       public String toString():返回此抽象路径名的路径名字符串D       public Boolean isFile():判断一个文件是否是普通文件,而不是目录正确答案: B  我的答案: D
  • Knowledge Point: InputStream is the parent class.

    InputStream类继承自FileInputStream,可以以字节为单位读取文件。A       trueB       false正确答案: B  我的答案: A
  • Knowledge Point: D: Throws an NullPointerException exception.

    下列关于public int read(byte[] b, int off, int len)方法的叙述,正确的是A       此方法覆盖了InputStream类中的read方法。B       此方法从该输入流中将最多len个字节的数据读入一个byte数组中。C       此方法返回读入缓冲区的字节总数,如果因为已经到达文件末尾而没有更多的数据,则返回-1。D       如果b为null,则会抛出IndexOutOfBoundsException异常。正确答案: A B C  我的答案: B C
  • Knowledge Points: Related concepts about subclasses of the Java.io class

    下列哪一个不是java.io类的子类?A       BufferedReaderB       BufferedWriterC       FileReaderD       FileWriterE       PrintReaderF       PrintWriter正确答案: E  我的答案: C
Summary of the sixth Zhou question
  • Knowledge Point: TreeSet

    下列关于泛型类的子类的说法,正确的个数为①LinkedList<E>泛型类创建一个链表结构的对象。②Stack<E>泛型类创建一个堆栈对象。③HashMap<E>泛型类创建散列映射。④DelayQueue<E>泛型类创建一个无界阻塞队列。⑤TreeSet<E>泛型类创建树映射。⑥Vector<E>创建可增长的对象数组。漏判了一个
  • Knowledge Point: B returns null if this mapping does not contain a mapping relationship for the key. c if the map previously contained a mapping of the key, the old value is replaced.

    下列关于HashMap<E>泛型类常用方法的介绍,正确的是A       public boolean isEmpty()如果此映射不包含键-值映射关系,则返回 true。B       public V get(Object key)返回指定键所映射的值;如果此映射不包含该键的映射关系,则抛出异常。C       public V put(K key, V value) 在此映射中关联指定值与指定键。如果该映射以前包含了一个该键的映射关系,则以先定义的值为准。D       public Object clone()返回此 HashMap 实例的浅表副本:并不复制键和值本身。正确答案: A D  我的答案: A B D
  • Knowledge Point: A: Throws an ClassCastException exception if the specified object cannot be compared to the current element in the set.

    下列关于TreeSet<E>泛型类常用方法的介绍,正确的是A       public boolean contains(Object o) 如果此 set 包含指定的元素,则返回 true。如果指定对象无法与该 set 中的当前元素进行比较,或不包含,则返回false。B       public boolean add(E e)将指定的元素添加到此 set。如果此 set 已经包含这样的元素,则该调用不改变此 set 并返回 false。C       public boolean addAll(Collection<? extends E> c)将指定 collection 中的所有元素添加到此 set 中。如果此 set 由于调用而发生更改,则返回 true。D       public E lower(E e) 返回此 set 中严格小于给定元素的最大元素;如果不存在这样的元素,则返回 null。正确答案: B C D  我的答案: A D
  • Knowledge Point: Length equals the number of Unicode code units in the string.

    String类中的length()方法用来获取一个String对象的字符序列的长度,单位为字节。A       trueB       false正确答案: B  我的答案: A
  • Knowledge Point: C: \b\w{6}\b matches exactly 6 characters of a word. F: Each number in an IP address cannot be greater than 255, and the expression ignores this constraint. The Right thing is ((2[0-4]\d|25[0-5]|[ 01]?\d\d?).) {3} (2[0-4]\d|25[0-5]| [01]?\d\d?].

    下列关于正则表达式的说法,正确的是A       \ba\w*\b匹配以字母a开头的单词B       \d+匹配1个或更多连续的数字。C       \b\w{6}\b 匹配6个及以上字符的单词。D       [0-9]代表的含意与\d就是完全一致的:一位数字E       \S+匹配不包含空白符的字符串。F       (\d{1,3}\.){3}\d{1,3}用来匹配 IP地址。正确答案: A B D E  我的答案: A B E F
  • Knowledge Point: ③: To find \ itself, you need to use \. ⑥: Note the character escapes, should be "" Hello "". Matches ("(["]) [^\ "']*\1").

      How many assertion statements are tested by the following tests? ①assertequals (True, "123". Matches ("\\d+")); ②assertequals (True, "3.5". Matches ("\\d\\.\\d")); ③assertequals (true, "C : \\Windows ". Matches (" C:\\Windows ")); ④assertequals (true," Hello Hello ". Matches (" \\b (? <word>\\w+) \\b\\s+\\k <word>\\b ") ⑤assertequals (" R*pl*c*m*nt "," Replacement ". ReplaceAll (" [Aeiou] "," * ")); ⑥assertequals (true," \ " Hello\ "". matches ([[\ "]) [^\" ']*\1 "); ⑦assertequals (" # # "," Xfooxxxxxxfoo ". ReplaceAll (". *?foo "," # ")); ⑧assertequals ("Let's Meet at [time].", "Let's Meet at 12:38." ReplaceAll ("(1|0?) [0-9]|2[0-3]):([0-5][0-9]) "," [Time] ")); A 7 B 6 c 4 x D 3 Correct answer: b My answer: C  
  • Knowledge Point: Java throws an exception if invalid date values is passed. There is no 40th on april-or any and month for that matter.

    What is the output of the following code?(下面代码的运行结果是?)LocalDate date = LocalDate.of(2018, Month.APRIL, 40);System.out.println(date.getYear() + " " + date.getMonth()+ " "+ date.getDayOfMonth());A       2018 APRIL 4B       2018 APRIL 30C       2018 MAY 10D       Another dateE       The code does not compile.F       A runtime exception is thrown.正确答案: F  我的答案: D
Pairing and mutual evaluation
    • Blogs that are worth learning or questions:
      • Elements Comprehensive
      • Very carefully and meticulously.
      • Typography Introduction Beautiful
    • Something worth learning or doing in your code:
      • Concise file Classification in code
      • Very serious.
reviewed the classmates blog and code
    • This week's study of the knot
      • 20165230
      • Pairs of learning content
        • Discuss the related applications of pairing programming
Other

Learned the MySQL client management tool, how to download the installation of MySQL and other database connections.

Learning progress Bar
lines of code (new/cumulative) Blog Volume (Add/accumulate) Learning Time (new/cumulative) Important Growth
Goal 5000 rows 30 Articles 400 hours
First week 48/48 1/1 20/20
Second week 390/438 2/3 18/38
Third week 866/1304 1/4 18/56
Week Four 1105/2409 1/5 30/86
Week Five 1229/3196 1/6 20/106
Week Six 1147/4343 2/8 25/131
Seventh Week 1222/3668 1/9 20/151

Try to record "planned learning time" and "actual learning time" to see if you can improve your planning skills by the end of the semester. This work is very important and useful in learning.
Formula for time-consuming estimation
: y=x+x/n, y=x-x/n, the number of training, X, Y is close.

Reference: Why is it so difficult to estimate software engineering applications, software engineering estimation methods

    • Planned study time: 30 hours

    • Actual learning time: 18 hours

    • Improved situation:

(See more modern software engineering courseware
Software engineer Competency Self-evaluation table)

Resources
    • Java Learning Notes (8th Edition)

    • Java Learning Note (8th Edition) Learning Guide

20165226 2017-2018-4 "Java Programming" 7th Week study Summary

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.