<%@ page language="java" contentType="text/html" import="java.sql.*"%> <% Connection conn; ResultSet resultSet; try { // Load the Oracle JDBC driver Class.forName("oracle.jdbc.driver.OracleDriver"); } catch(ClassNotFoundException e) { System.out.println("Driver not found."); System.out.println(e.toString()); throw new UnavailableException(this, "Class not found."); } try { // Connect to the Database conn = DriverManager.getConnection("jdbc:oracle:thin:@opal:1521:RAB1", "scott", "tiger"); Statement statement = conn.createStatement(); resultSet = statement.executeQuery("SELECT empno, ename, job," + " NVL(TO_CHAR(mgr), '---') \"mgr\"," + " TO_CHAR(hiredate, 'DD.MM.YYYY') \"hiredate\"," + " NVL(TO_CHAR(sal), '0') \"sal\"," + " NVL(TO_CHAR(comm), '0') \"comm\"," + " RPAD(TO_CHAR(deptno), 6, ' ') \"deptno\"" + " FROM emp order by ename"); } catch(SQLException e) { System.out.println("An error occurs."); System.out.println(e.toString()); throw new UnavailableException(this, "Cannot connect with the specified database."); } %> Access to Oracle9i Database on Akadias Site

Select * from EMP


Connection settings:
  getAutoCommit = <%=conn.getAutoCommit()%>
  getCatalog = <%=conn.getCatalog()%>
  getTransactionIsolation = <%=conn.getTransactionIsolation()%>
  isClosed = <%=conn.isClosed()%>
  isReadOnly = <%=conn.isReadOnly()%>

Return result:

<% int countrows = 0; %> <% while (resultSet.next()) { %> <% countrows++; %> <% } %>
<%= resultSet.getString("empno") %> <%= resultSet.getString("ename") %> <%= resultSet.getString("job") %> <%= resultSet.getString("mgr") %> <%= resultSet.getString("hiredate") %> <%= resultSet.getString("sal") %> <%= resultSet.getString("comm") %> <%= resultSet.getString("deptno") %>

<%=countrows%> row(s) found.


Show JSP source