0

Hi Experts,

i have this code --

<%-- 
    Document   : index
    Created on : Nov 10, 2008, 3:25:29 PM
    Author     : namish
--%>

<%@page import="java.sql.*"%>


<html>
<head>
<title>Obtaining a Connection</title>
</head>
<body>
<h1>This Page Obtains a Connection to a Database and executes a query</h1>
<%
    Connection conn = null;
    ResultSet result = null;
    Statement stmt = null;


    try {
      Class c = Class.forName("oracle.jdbc.driver.OracleDriver");
    }
    catch (Exception e) {
      System.out.println("Error occurred " + e);
     }
     try {
       conn = DriverManager.getConnection("jdbc:oracle:thin:nameesh/dost1234@(description=(address_list=(address=(protocol=tcp) (host=arcot-w2kts01)(port=1521))) (source_route=yes)(connect_data=(sid=ts)))"); 


     }
     catch (SQLException e) {
        System.out.println("Error occurred " + e);
     }
     try {
        stmt = conn.createStatement();
        result = stmt.executeQuery("SELECT * FROM ARUSER; ");
        int count=0;
        while (result.next())
        {
        System.out.println("UserName :: "+result.getString(1)+" , Groupname :: "+result.getString(2)+" , Firstname :: "+result.getString(3)+" ,Latname :: "+result.getString(4)+" ,Pam :: "+result.getString(5)+" , Email :: "+result.getString(6));
        count++;
        }
        System.out.println(count+" records selected...");

     }
     catch (SQLException e) {
         System.out.println("Error occurred " + e);
      }

%>

in this i am only getting the header part but the jsp part is not run.
what can be the problem here. when i ran this jsp i got "This Page Obtains a Connection to a Database and executes a query", but the desired output is the result of the query.I am doing something wrong here.

Thanks
NT

2
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by masijade
0

Yes you are, and that "doing something wrong" is using scriptlets, period. Move all of that scriptlet stuff out into a bean or two and use the "useBean" tag.

0

i could not understand what u said, as i am totally new to these terminologies.
can you please guide me to do so.
I will be thankful for your help..

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.