📄 db_form.xtp
字号:
<s1 title="Database"><p>Resin provides a interface to database pooling followingJDBC. Database pools are named, identifying a configuration. TheJSP or Bean can be written independent of the database vendor or driver.</p><example title='Storing a Survey in a Database'><%@ page language=java %><%@ page import='java.sql.*' %><%@ page import='javax.sql.*' %><%@ page import='javax.naming.*' %><%Context env = (Context) new InitialContext().lookup("java:comp/env");DataSource source = (DataSource) env.lookup("jdbc/test_db");Connection conn = source.getConnection();try { Statement stmt = conn.createStatement(); String name = request.getParameter("name"); String color = request.getParameter("color"); stmt.executeUpdate( "insert into COLORS values (" + "'" + name + "', '" + color + "')" );} finally { conn.close();}%><h1>Thank you, <%= name %></h1></example><p><code/DataSource/> is the standard Java API for obtaining newdatabase connections.<p>Closing the connection automatically returns it to the database pool.It is very important that you use the <var/try ... finally/> pattern tomake sure the connections get returned to the pool.</s1>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -