<%@ page contenttype="text/html; charset=gbk" %>
<%@ page import="java.sql.*";
page import="java.io.ioexception ",
page import="javax.naming.context ",
page import="javax.naming.initialcontext ",
page import="javax.sql.datasource " %>
<%!
java.sql.connection conn;
statement stmt=null;
java.sql.resultset rs=null;
int flag=0;
javax.sql.datasource ds=null;
public void jspinit(){
try{
javax.naming.initialcontext initx = new javax.naming.initialcontext();
ds = (javax.sql.datasource )initx.lookup("testjndi") ;//jndiname
conn = ds.getconnection() ;
}
catch(exception ea){
}
}
%>
<html>
<head>
<title>
jsp1
</title>
</head>
<body>
<%
stmt=conn.createstatement() ;
rs =stmt.executequery("select * from province") ;
if (rs==null){
out.print("rs is null");
}
while(rs.next() ){
out.print(rs.getstring("province_name")) ;
}
%>
<h1>
jbuilder generated jsp
</h1>
<form method="post">
<br>enter new value : <input name="sample"><br>
<br><br>
<input type="submit" name="submit" value="submit">
<input type="reset" value="reset">
<br>
</form>
</body>
</html>
