javax.naming.*,
javax.sql.DataSource,
java.sql.*"%>
<html>
<body Color bgcolor; bgcolor=Color.Blue>
<p><font size="6">This is the result from:"select 'YES' YES from dual":
<%
DataSource cname = null;
Connection cont = null;
PreparedStatement stmt = null;
InitialContext ctx;
try {
ctx = new InitialContext();
cname = (DataSource)ctx.lookup("SOADS");
cont = cname.getConnection();
stmt = cont.prepareStatement("select BANNER from SYS.V_$VERSION");
ResultSet sr = stmt.executeQuery();
while (sr.next()) {
out.println("<br> " +sr.getString(1));
}
sr.close();
stmt.close();
}catch(Exception excep){
out.println("Exception Encountered " +excep);
}finally{
if(cont != null){
cont.close();
}
} %></font></p>
</body>
</html>
sql.jsp:
<%@page contentType="text/html"
import="java.util.*,
javax.naming.*,
javax.sql.DataSource,
java.sql.*,
java.io.*,
oracle.jdbc.*,
oracle.jdbc.driver.*,
oracle.jdbc.pool.*,
oracle.sql.*"%>
<html>
<body>
<p><font size="3">This is the result from:"PLSQL Execution ...":
<%
DataSource cname = null;
Connection cont = null;
CallableStatement stmt = null;
String oraclProc = (" begin ? :=change.test(?); end;");
InitialContext ctx;
try {
ctx = new InitialContext();
cname = (DataSource)ctx.lookup("SOADS");
cont = cname.getConnection();
stmt = cont.prepareCall(oraclProc);
stmt.registerOutParameter(1,Types.VARCHAR);
stmt.setString(2, "Yummy");
stmt.execute();
out.println(stmt.getString(1));
stmt.close();
}catch(Exception excep){
System.out.println("Exception Encountered " +excep);
out.println("<br>"+"Exception Encountered " +excep);
}
finally{
if(cont != null){
cont.close();
}
if(stmt != null){
stmt.close();
}
} %></font></p>
</body>
</html>
plsql1.jsp:
<%@page contentType="text/html"
import="java.util.*,
javax.naming.*,
javax.sql.DataSource,
java.sql.*,
java.io.*,
oracle.jdbc.*,
oracle.jdbc.driver.*,
oracle.jdbc.pool.*,
oracle.sql.*"%>
<html>
<body >
<pre style="font-family: Verdana, Arial, sans serif;">
<p>This is the result from:"PLSQL Execution ...":
<%
ResultSet ors;
DataSource cname = null;
Connection cont = null;
Statement stmt = null;
String oraquery = ("select owner,name,type from v$db_object_cache where kept='YES' order by
owner");
InitialContext ctx;
try {
ctx = new InitialContext();
cname = (DataSource)ctx.lookup("SOADS");
cont = cname.getConnection();
stmt = cont.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
out.println("\nExecuting query: " + oraquery );
out.println("\n");
out.println("OWNER"+"<HTML>	"+"NAME"+"<HTML>	"+"<HTML>	"+"<HTML>	"+"<HTML>�
9;"+"<HTML>	"+"<HTML>	"+"<HTML>	"+"TYPE");
out.println("--------------------------------------------------------------------------");
ors = stmt.executeQuery(oraquery);
while (ors.next()) {
out.println(ors.getString(1) +"<HTML>	"+"<HTML>	"+ ors.getString(2) +"<
HTML>	" +"<HTML>	"+"<HTML>	"+ ors.getString(3));
}
stmt.close();
}catch(Exception excep){
System.out.println("Exception Encountered " +excep);
out.println("<br>"+"Exception Encountered " +excep);
}
finally{
if(cont != null){
cont.close();
}
if(stmt != null){
stmt.close();
}
} %></font></p>
</pre>
</body>
</html>
ver.jsp:
<%@page contentType="text/html"
import="java.util.*,
javax.naming.*,
javax.sql.DataSource,
java.sql.*,
oracle.jdbc.*,
oracle.sql.*"%>
<%
DataSource cname = null;
Connection cont = null;
InitialContext ctx;
try {
ctx = new InitialContext();
cname = (DataSource)ctx.lookup("SOADS");
cont = cname.getConnection();
// Create Oracle DatabaseMetaData object
DatabaseMetaData meta = cont.getMetaData();
// gets driver info:
System.out.println("JDBC driver version is " + meta.getDriverVersion());
out.println("<br> "+"JDBC driver version is " + meta.getDriverVersion());
}
catch(Exception excep){
out.println("Exception Encountered " +excep);
}
finally{
if(cont != null){
cont.close();
}
}
%>