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