"Software Testing" experiment five: Testing technology

Source: Internet
Author: User

First, find out the problems in the function.

1. Please add a comment to the class and each method in Mysqlconnbean.java

Package Org.easybooks.bookstore.jdbc;import java.sql.*;p ublic class Mysqlconnbean {private Statement stmt=null; Private Connection conn=null;private ResultSet rs=null;//Open database connection by driver, MySQL user name password public void Openconn () throws Exception {class.forname ("com.mysql.jdbc.Driver"); String url= "Jdbc:mysql://localhost:3306/test"; String user= "root"; String password= "123456"; conn=drivermanager.getconnection (url, user, password);} Executes the database statement and returns the result set public ResultSet ExecQuery (String sql) {rs=null;try{stmt=conn.createstatement (resultset.type_ Scroll_sensitive, resultset.concur_read_only); rs=stmt.executequery (SQL);} catch (SQLException e) {System.err.println ("Data.executequery:" +e.getmessage ());} return RS;} Close statementpublic void closestmt () {try{stmt.close ();} catch (SQLException e) {System.err.println ("Data.executequery:" +e.getmessage ());}} Close database connection public void Closeconn () {try{conn.close ();} catch (SQLException e) {System.err.println ("Data.executequery:" +e.getmessage ());}}}

1, find out the defects in the project, and give solutions (at least 3, do not include the following example).

Note: The flaws mentioned here are not necessarily errors, but areas where improvements are obvious.

Such as: Can not enter the password unlimited, easy to be brute force, there is a security risk.

Solution: Password entered 3 times error, close the browser. It is best to add a verification code.

① problem: In the Openconn () method, a connection database error occurs if the driver or user name password is incorrect

FIX: Add try catch to catch database connection error exception and handle exception

② problem: You can also access the welcome.jsp page without landing

Resolution: Increase access rights, only login to access

③ problem: The user name password is not encrypted at the time of registration and is transmitted in clear text on the Validate page

FIX: Use MD5 encryption when registering

Second, please follow the requirements of the following Java code test. The function of the code is to look for an element with a value of key in an array of elements in ascending order using binary lookup.

(1) The basic path method is required to give the program control flow graph;

(1) Calculate loop complexity

Loop complexity = Number of Regions +1=3+1=4

Software Test Experiment five: test technology

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.