public class ConnectionServlet_21
extends javax.servlet.http.HttpServlet
This is a simple servlet that holds a global connection pool. The Servlet context is used to store a named attribute (this servlet) so that other servlets have access to the connection pool
限定符和类型 | 字段和说明 |
---|---|
static java.lang.String |
KEY |
构造器和说明 |
---|
ConnectionServlet_21() |
限定符和类型 | 方法和说明 |
---|---|
void |
close(java.sql.Connection con)
Closes the given JDBC connection
|
void |
close(java.lang.String sector,
java.sql.Connection con) |
void |
destroy()
Destroy the servlet.
|
java.sql.Connection |
getConnection()
Get a JDBC connection from the pool
|
java.sql.Connection |
getConnection(java.lang.String sector) |
java.lang.String[] |
getSectors(java.lang.String cfgFileName)
获取配置文件中数据库连接的名字
|
void |
init(javax.servlet.ServletConfig cfg)
Initialize the servlet.
|
public java.sql.Connection getConnection() throws java.lang.Exception
java.lang.Exception
- Exceptionpublic java.sql.Connection getConnection(java.lang.String sector) throws java.lang.Exception
java.lang.Exception
public void close(java.sql.Connection con)
Closes the given JDBC connection
con
- JDBC Connectionpublic void close(java.lang.String sector, java.sql.Connection con)
public void init(javax.servlet.ServletConfig cfg) throws javax.servlet.ServletException
Initialize the servlet. This is called once when the servlet is loaded. It is guaranteed to complete before any requests are made to the servlet
init
在接口中 javax.servlet.Servlet
init
在类中 javax.servlet.GenericServlet
cfg
- Servlet configuration informationjavax.servlet.ServletException
public void destroy()
Destroy the servlet. This is called once when the servlet is unloaded.
destroy
在接口中 javax.servlet.Servlet
destroy
在类中 javax.servlet.GenericServlet
public java.lang.String[] getSectors(java.lang.String cfgFileName) throws java.lang.Exception
cfgFileName
- String 配置文件java.lang.Exception
- 异常