Re: Problem connection to an Oracle Database ??

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Greg Forestieri

    Re: Problem connection to an Oracle Database ??

    nelson.broat@ma il.cuny.edu (Nelson Broat) wrote in message news:<32159d9d. 0308060756.218f a22e@posting.go ogle.com>...
    Hi, I could use some advice. I'm not sure if this is simply a matter
    of improperly displaying results that have been returned, or one of
    not properly connecting to the database. What follows is a jsp I
    threw together to pull data from a table and display it dynamically
    within my I.E. browser.
    >
    Did I include all the neccessary Classpaths? When the first classpath
    was included with all of the rest on my second IMPORT statement, I
    kept receiving "could not compile" error messages. So I put it in
    its own IMPORT statement.
    >
    Am I issuing the appropriate getConnection method? Thanks for any and
    all advice. Appreciate it. Here is the jsp:
    >
    <%@ page import="com.epi centric.jdbc.*" %>
    >
    <%@ page import="java.ut il.*,
    java.text.*,
    java.io.*,
    java.net.URL,
    com.epicentric. common.*,
    java.sql.*"
    %>
    >
    <%@ include file="/include/common.jsp"%>
    >
    <%@taglib uri="epi-tags" prefix="epi_htm l" %>
    <%@taglib uri="module-tags" prefix="mod" %>
    <epi_html:contr ollerURL />
    <epi_html:check Ticket />
    >
    <%
    >
    //instantiate variables
    Connection con = null;
    Statement stmt = null;
    ResultSet rs = null;
    >
    try {
    //Load the JDBC driver
    Class.forName(" oracle.jdbc.dri ver.OracleDrive r").newInstance ();
    >
    //Get the connection getConnection(" oracle driver", "userID",
    "password")
    con = DriverManager.g etConnection("j dbc:oracle:thin :@dns_name:port number:oracle_i nstancename","u serid","passwor d");
    >
    stmt = con.createState ment();
    >
    //sql statements: create, update, query
    rs = stmt.executeQue ry("SELECT * FROM DB.DB_RESOURCE WHERE
    DB.DB_RESOURCE. CODE = '**'");
    >
    while (rs.next())
    System.out.prin tln(rs.getStrin g(1));
    >
    rs.close();
    stmt.close();
    con.close();
    }
    catch(Exception ex) {
    System.out.prin tln("Error " + ex.toString());
    >
    }
    %>
    >
    Nelson
    Hate to be a smart@ss but you missed the model railroading and French
    cooking forums. ;)
  • Nelson Broat

    #2
    Re: Problem connection to an Oracle Database ??

    Problem resolved. I was connecting to the database correctly. What I
    wasn't doing correctly getting data to output. I was using
    "system.out.pri ntln" instead
    of "out.printl n".

    Thanks for the suggestion Rauf.

    Nelson

    Comment

    Working...