Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Problem connection to an Oracle Database ??

Problem connection to an Oracle Database ??

From: Nelson Broat <nelson.broat_at_mail.cuny.edu>
Date: 6 Aug 2003 08:56:11 -0700
Message-ID: <32159d9d.0308060756.218fa22e@posting.google.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.epicentric.jdbc.*"%>

<%@ page import="java.util.*,

    java.text.*, 
    java.io.*, 
    java.net.URL, 

    com.epicentric.common.*,
    java.sql.*"
%>

<%@ include file="/include/common.jsp"%>

<%_at_taglib uri="epi-tags" prefix="epi_html" %>
<%_at_taglib uri="module-tags" prefix="mod" %>
<epi_html:controllerURL />
<epi_html:checkTicket />

<%

//instantiate variables
Connection con = null;
Statement stmt = null;
ResultSet rs = null;

try {
//Load the JDBC driver
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();

//Get the connection getConnection("oracle driver", "userID", "password")
con = DriverManager.getConnection("jdbc:oracle:thin:@dns_name:portnumber:oracle_instancename","userid","password");

stmt = con.createStatement();

//sql statements: create, update, query
rs = stmt.executeQuery("SELECT * FROM DB.DB_RESOURCE WHERE DB.DB_RESOURCE.CODE = '**'"); while (rs.next())
 System.out.println(rs.getString(1));

rs.close();
stmt.close();
con.close();

    }
    catch(Exception ex) {

            System.out.println("Error " + ex.toString());             

    }
%>

Nelson Received on Wed Aug 06 2003 - 10:56:11 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US