DEE

数据交换


[根据名称获取数据源]

<p><strong>方法签名:</strong> </p> <p><code>getDsByName(name)</code></p> <p><strong>简要描述:</strong> </p> <ul> <li>根据名称获取数据源</li> </ul> <p><strong>参数:</strong> </p> <table> <thead> <tr> <th style="text-align: left;">参数名</th> <th style="text-align: left;">类型</th> <th style="text-align: left;">说明</th> </tr> </thead> <tbody> <tr> <td style="text-align: left;">name</td> <td style="text-align: left;">String</td> <td style="text-align: left;">数据源名称</td> </tr> </tbody> </table> <p><strong>返回值说明</strong> </p> <table> <thead> <tr> <th style="text-align: left;">类型</th> <th style="text-align: left;">说明</th> </tr> </thead> <tbody> <tr> <td style="text-align: left;">com.seeyon.v3x.dee.resource.DbDataSource</td> <td style="text-align: left;">数据源对象</td> </tr> </tbody> </table> <p><strong>使用例子</strong></p> <pre><code>import java.sql.ResultSet; import java.sql.Statement; import java.sql.Connection; import java.sql.SQLException; import com.seeyon.v3x.dee.resource.DbDataSource; DbDataSource ds = getDsByName(&amp;quot;local&amp;quot;); //获取数据源 Connection connection = ds.getConnection();//获取连接 Statement stmt = null; ResultSet rs = null; String sql = &amp;quot;select * from test&amp;quot;;//sql try { stmt = connection.createStatement(); rs = stmt.executeQuery(sql);//执行sql,并获取返回值 while(rs.next()){ println( rs.getObject(&amp;quot;id&amp;quot;))//打印返回值中所有“id”字段的值 } } catch (SQLException e) { throw e; }finally{//释放资源,必须要做 rs.close(); stmt.close(); connection.close(); }</code></pre> <p><strong>输出结果</strong></p> <pre><code>1001 1002 1003 1004</code></pre> <p><strong>备注</strong> </p> <ul> <li>无</li> </ul>

页面列表

ITEM_HTML