Re: Problem connection to an Oracle Database ??

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rauf Sarwar

    Re: Problem connection to an Oracle Database ??


    Originally posted by Nelson Broat
    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 num-
    ber:oracle_inst ancename","user id","password") ;
    >
    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

    Have you included Oracle jdbc driver in your classpath? Depending on
    your Oracle version, it would be ORACLE_HOME/jdbc/lib/classesXXX.zip or
    classesXXX.jar file.

    Regards
    /Rauf

    --
    Posted via http://dbforums.com
Working...