db_form.xtp

来自「解压在c盘」· XTP 代码 · 共 45 行

XTP
45
字号
<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'>&lt;%@ page language=java %&gt;&lt;%@ page import='java.sql.*' %&gt;&lt;%@ page import='javax.sql.*' %&gt;&lt;%@ page import='javax.naming.*' %&gt;&lt;%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();}%&gt;&lt;h1&gt;Thank you, &lt;%= name %&gt;&lt;/h1&gt;</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 + =
减小字号Ctrl + -
显示快捷键?