Note that there are some explanatory texts on larger screens.

plurals
  1. POCannot make database connection due to servlet errors
    text
    copied!<p>In the below code I have two files. One is for my database connectivity and the other is for my html based jsp file. I am attempting to check the version of my database and print it to the screen. I am trying to return the value of CheckVersion and use out.println to put it on the webpage.</p> <p>I am getting the follow errors.</p> <blockquote> <p>type Exception report</p> <p>message</p> <p>descriptionThe server encountered an internal error () that prevented it from fulfilling this request.</p> <p>exception</p> <p>org.apache.jasper.JasperException: PWC6033: Error in Javac compilation for JSP</p> <p>PWC6199: Generated servlet error: package com.sun.xml.rpc.processor.modeler.j2ee.xml does not exist</p> <p>PWC6199: Generated servlet error: package databaseFiles does not exist</p> <p>PWC6197: An error occurred at line: 18 in the jsp file: /index.jsp PWC6199: Generated servlet error: cannot find symbol symbol: class DatabaseManagement location: class org.apache.jsp.index_jsp</p> <p>PWC6197: An error occurred at line: 18 in the jsp file: /index.jsp PWC6199: Generated servlet error: cannot find symbol symbol: class DatabaseManagement location: class org.apache.jsp.index_jsp</p> </blockquote> <p>What am I doing wrong? I am using netbeans and it is not reporting any problems with the way I created my file. index.jsp is in the root area and I created a folder named databaseFiles that is holding my DatabaseManagement.java file.</p> <p>Thanks.</p> <pre><code>/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package databaseFiles; import com.sun.corba.se.impl.util.Version; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.logging.Level; import java.util.logging.Logger; /** * * @author Aaron */ public class DatabaseManagement { private final String urlDB = "jdbc:mysql://correct:3306/javaBBS"; private final String userDB = "correct"; private final String passwordDB = "correct"; Connection conDB = null; Statement st = null; ResultSet rs = null; /* * * */ public DatabaseManagement() { } /* * */ public void OpenConnection() { try { try { Class.forName("com.mysql.jdbc.Driver"); } catch(Exception e) { System.out.println("Could not load database driver"); } conDB = DriverManager.getConnection(urlDB, userDB, passwordDB); } catch(SQLException ex) { Logger lgr = Logger.getLogger(Version.class.getName()); lgr.log(Level.SEVERE, ex.getMessage(), ex); } } /* * Closes the current database object */ public void CloseConnection() { try { if (rs != null) { rs.close(); } if (st != null) { st.close(); } if (conDB != null) { conDB.close(); } } catch (SQLException ex) { Logger lgr = Logger.getLogger(Version.class.getName()); lgr.log(Level.WARNING, ex.getMessage(), ex); } } /** * Checks the database version */ public String CheckVersion() throws SQLException { try { st = conDB.createStatement(); rs = st.executeQuery("SELECT VERSION()"); } catch(Exception e) { System.out.println("Could not get the version of the DB."); } if (rs.next()) { System.out.println(rs.getString(1)); } return rs.getString(1); } } </code></pre> <p>The below is index.jsp.</p> <pre><code>&lt;%-- Document : index Created on : May 30, 2013, 1:48:03 PM Author : Aaron --%&gt; &lt;%@page import="com.sun.xml.rpc.processor.modeler.j2ee.xml.string"%&gt; &lt;%@page import="databaseFiles.DatabaseManagement"%&gt; &lt;%@page contentType="text/html" pageEncoding="UTF-8"%&gt; &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt; &lt;title&gt;JSP Page&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt;Hello World!&lt;/h1&gt; &lt;% out.println("&lt;br/&gt;Your IP address is " + request.getRemoteAddr()); String userAgent = request.getHeader("user-agent"); String browser = "unknown"; out.print("&lt;br/&gt;and your browser is "); if (userAgent != null) { if (userAgent.indexOf("MSIE") &gt; -1) { browser = "MS Internet Explorer"; } else if (userAgent.indexOf("Firefox") &gt; -1) { browser = "Mozilla Firefox"; } else if (userAgent.indexOf("Opera") &gt; -1) { browser = "Opera"; } else if (userAgent.indexOf("Chrome") &gt; -1) { browser = "Google Chrome"; } else if (userAgent.indexOf("Safari") &gt; -1) { browser = "Apple Safari"; } } out.println(browser); DatabaseManagement dbConnector = new DatabaseManagement(); dbConnector.OpenConnection(); out.println(dbConnector.CheckVersion()); dbConnector.CloseConnection(); %&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload