servlet&jsp Chapter 9 JDBC Connection

In Chapter 9 of the servlet notes, 9.1.2 Connecting to the database, the DbBean.java instance in JDBCDemo, it is found that when an exception occurs in the DriverManagere.getConnection(....) link, it should not throw new ...Exception(..) , If this is the case, an exception will be reported in jsp instead of showing a connection failure!
ps: Don't forget to import the mysql driver jar package in the lib directory of WEB-INFO.
Download address: https://dev.mysql.com/downloads/connector/j/

In fact, web applications rarely obtain the connection directly from Drivermanager in this way, but obtain the set DataSource on the server through JNDI. DataSource obtains Connection.


9.1.3 Using Statement, Resultset
often important information is inconspicuous vocabulary. Connection is the representative object of connecting to the database. If you want to execute sql next, you need to obtain java.sal.Statement, and statement is the representative object of the sql statement. You can use Statemnet st = Connection.createStatement() to get the statement object.

In guestbook.jsp, how to add information if a new message is added? ? ? ? ? ? ? ? ?

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326261956&siteId=291194637