troubleshooting Question

jdbc setup in code

Avatar of annie613
annie613 asked on
7 Comments1 Solution269 ViewsLast Modified:
is there something missing in my code. i have a class to set up my jdbc connections to my db

public class aug
  //privarte variables
  private Connection conn = null;
  private DataSource ds = null;
  private PreparedStatement ps = null;
  private ResultSet rs = null;
  private static final String dataSource = "jdbc/aug";
  private String message = "";

  public static final String getTypeQuery =
    "select TYPE_DESC from TYPE where ACTIVE_FLAG = 1";
  public ArrayList getType()
    ArrayList TypeList = new ArrayList();

      ps = conn.prepareStatement(getTypeQuery);
      rs = (ResultSet)ps.executeQuery();
      while (
    catch (Exception e)
      System.out.println("exception for getType(): " + e.toString());
      catch (Exception e){}
    System.out.println("TypeList = " + TypeList);
    return miprTypeList;

  private void makeConnection() throws Exception
      if (conn != null)
      InitialContext ic = new InitialContext();
      DataSource ds = (DataSource) ic.lookup(dataSource);

      conn = ds.getConnection();
    catch (Exception ex)
      throw new Exception("Unable to connect to database. " + ex.getMessage());

  private void releaseConnection() throws Exception
      if (ps != null)
      if (rs != null)
      if (conn != null)
    } //try
    catch (SQLException ex)
      throw new Exception("releaseConnection: " + ex.getMessage());

and i have a jsp file to display my arrayList
<%@ page contentType="text/html;charset=windows-1252"%>

<%@ page import="java.util.*"%>
<%@ page import="java.text.*"%>
<%@ page errorPage="error.jsp"%>

<jsp:useBean id='in' scope='page' class='aug.aug'/>

  String pageTitle = "Search By:";
  response.setHeader("Pragma", "no-cache");
  response.setHeader("Cache-Control", "no-cache, post-check=0, pre-check=0");

  ArrayList TypeList = in.getType();


    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <link href="./css/aug.css" rel="stylesheet" media="screen"/>

    <form name="search" id="search" action="display.jsp" method="POST" onsubmit="return validateFormData();">

      <DIV align="center">
      <table cellspacing="2" cellpadding="3" border="1" width="41%">
            <td width="23%">TYPE</td>
            <td width="77%" style="font-size:x-small;">
              <select name="type">
              <%for (int typectr = 0; typectr < TypeList.size(); typectr++)
              <option value="<%=TypeList.get(typectr)%>"><%=TypeList.get(typectr)%></option>
              </select> &nbsp;*one type must always be selected
      <P align="center">
        <input type="submit" value="Search" name="Search"/>
        <input type="reset" value="Reset" name="Reset"/>

    TypeList=  <%=TypeList%>


when i compile the files --- all runs well -- my jsp page displays but then i get an exception

exception for getTypeQuery: java.lang.Exception: Unable to connect to database. jdbc/aug not found
but i know my DB is running ---- am i missing something in my code or the setup of the workspace that it wont display??

any suggestions? thanks in advance! cheers annie
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 7 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros