<!
使用连接池获得连接JNDI java name dri interface java命名目录接口
>
<! 获得连接 > <%
Context context = new InitialContext()
DataSource ds = (DataSource)contextlookup(java:/comp/env/jdbc/oracle)
Connection conn = dsgetConnection()
PreparedStatement ps = connprepareStatement(select * from teleinfo)
ResultSet rs = psexecuteQuery()
while(rsnext())
{
outprintln(rsgetString())
outprintln()
}
connclose() %>
在应用的
contextxml
中如下配置
<Context> …… ……<Resource name=jdbc/oracle auth=Container type=javaxsqlDataSource
maxActive=
maxIdle=
maxWait=
username=telecom
password=orcl
driverClassName=oraclejdbcdriverOracleDriver
url=jdbc:oracle:thin:@localhost::ORCL/> </Context>