Question: Eclipse/Oracle Problems I am trying to follow a youtube guide and ran into an error. I am getting the following message even when I copy

Eclipse/Oracle Problems

I am trying to follow a youtube guide and ran into an error. I am getting the following message even when I copy code exactly.

I am using localhost, hr/hr, and oracle 11g with jdbc6 in the lib.

Please show me how and where to fix the code or direct me in how to set this up. Will upvote!

Exception Report

Message An exception occurred processing [/listCustomers.jsp] at line [17]

Description The server encountered an unexpected condition that prevented it from fulfilling the request.

Exception

org.apache.jasper.JasperException: An exception occurred processing [/listCustomers.jsp] at line [17] 14:  15: <%@ include file="header.html"%> 16: 

List of Participating Companies

17: 18: select * from business 19: order by bus_name 20: Stacktrace: org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:607) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:481) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330) javax.servlet.http.HttpServlet.service(HttpServlet.java:741) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)

Root Cause

javax.servlet.ServletException: javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "java.sql.SQLException: Listener refused the connection with the following error: ORA-12505, TNS:listener does not currently know of SID given in connect descriptor " org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:667) org.apache.jsp.listCustomers_jsp._jspService(listCustomers_jsp.java:190) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:741) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:458) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330) javax.servlet.http.HttpServlet.service(HttpServlet.java:741) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) 

Root Cause

javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "java.sql.SQLException: Listener refused the connection with the following error: ORA-12505, TNS:listener does not currently know of SID given in connect descriptor " org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.getConnection(QueryTagSupport.java:285) org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.doStartTag(QueryTagSupport.java:168) org.apache.jsp.listCustomers_jsp._jspx_meth_sql_005fquery_005f0(listCustomers_jsp.java:214) org.apache.jsp.listCustomers_jsp._jspService(listCustomers_jsp.java:158) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:741) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:458) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330) javax.servlet.http.HttpServlet.service(HttpServlet.java:741) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) 

-------------------------------------------------------

Here is my code:

listCustomers.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"

pageEncoding="ISO-8859-1"%>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>

List of Participating Companies

<%@ include file="header.html"%>

List of Participating Companies

select * from business

order by bus_name

Business Number Business Name Category Contract End Date
${customer.bus_num} ${customer.bus_name} ${customer.bus_category} ${customer.bus_contractend}

--------------------------------------------------------------

DatabaseListener.java

import javax.servlet.ServletContext;

import javax.servlet.ServletContextEvent;

import javax.servlet.ServletContextListener;

import javax.servlet.annotation.WebListener;

import oracle.jdbc.pool.OracleDataSource;

@WebListener

public class DatabaseListener implements ServletContextListener {

public void contextDestroyed(ServletContextEvent arg0) {

}

public void contextInitialized(ServletContextEvent sce) {

ServletContext ctx = sce.getServletContext();

try {

OracleDataSource ods = new OracleDataSource();

ods.setUser("hr");

ods.setPassword("hr");

ods.setURL("jdbc:oracle:thin:@localhost:1521:xe");

ctx.setAttribute("oracleDataSource", ods);

System.out.println("Created OracleDataSource successfully!");

} catch(Exception ex) {

System.out.println("Error : " + ex.getMessage());

}

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!