where =? "; Preip = conn.preparestatement (SQL); prep.setString (1," "); Rset = preip.executeQuery (); if (Rset.Next ()) {System.out.println ("
The above example is the most common way to operate in JSP.
In the application, it is often necessary to operate the database. Every time you write the above code, it is definitely more troublesome. You need to extract the unmatched part of it, make an interface, which introduces a Facade look. If we replace the Class. in Forname is also very convenient, such as replacing the Oracle database from the MySQL database, as long as the Driver in the Facade interface can be replaced.
We have made a FACADE interface, using this interface, the program in the previous example can be changed as follows:
Public class dbcompare {string SQL = "SELECT * from
where =?"; try {mysql msql = new mysql (sql); prep.setstring (1, ""); Rset = Prep.executeQuery (); if (Rset.Next ()) {system.out.println (RSET.GETSTRING ("
It can be seen very simple, all programs are used to access databases, reducing the complexity of the system, increasing flexibility.
If we want to use the connection pool, you can modify the FACADE interface.
As can be seen from the figure, FACADE is actually a common way to reduce system relationships, reducing a common method of inter-system coupling, maybe you are not known, although I don't know it is facade.