Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2011
    Rep Power

    Default Trouble using JSP for MySQL database

    Title is pretty self explanatory, but the exact error I'm getting when I try to view my page is:

    exception occurred processing JSP page /movies.jsp at line 17

    Java Code:
    14:    cs += "?user=root&password=********";
    16:    //Establish Connection
    17:    Connection cxn = DriverManager.getConnection(cs);

    This is the full code on the page.
    Java Code:
    		<title>Movie Catalog</title>
    <%@ include file="header.htm" %>
    <%@ page import="java.sql.*" %>
    	//Load driver
    	//Build Connection
    	String cs="jdbc:mysql://localhost:3306/forta";
    	cs += "?user=root&password=bcis3680";
    	//Establish Connection
    	Connection cxn = DriverManager.getConnection(cs);
    	//Create Statement
    	Statement stm = cxn.createStatement();
    	String query = "SELECT movie.mid, movie.title, movie.genre, movie.mpaa, " +
    		"movie.rlsdate,, ( FROM movie";
    	ResultSet rs = stm.executeQuery(query);
    		<h1><FONT COLOR="B22222">Movies Catalog</FONT></h1><br />
    		<th>Movie ID</th><th>Title</th><th>Genre</th><th>MPAA</th><th>Release Date</th>
    	<% while({ %>
    		<td align=center><%= rs.getString("mid")%> </td>
    		<td align=center><%= rs.getString("title")%> </td>
    		<td align=center><%= rs.getString("genre")%> </td>
    		<td align=center><%= rs.getString("mpaa")%> </td>
    		<td align=center><%= rs.getString("rlsdate")%> </td>
    		<td align=center><%= rs.getString("box")%> </td>
    		<td align=center><%= rs.getString("box/budget")%> </td>
    		<br /><br />
    		<%@ include file="footer.htm" %>
    I'm pretty new to the JSP stuff and this is my first go at trying to get a db to display on a web page. Any suggestions or help would be greatly appreciated.
    Last edited by killasaurus tex; 04-13-2011 at 02:06 AM.

  2. #2
    Join Date
    Feb 2011
    Rep Power


    Okay, I found the problem I was having, now I have another.

    As you can see in the code, I'm trying to make a table for some movie information and I am supposed to calculate their ROI. I was wondering how I can do this in the JSP page. The way I have it now does not seem to be working for me and I've had trouble finding anything online. I have the two fields in my sql pages to be able to do it (budget and box), but I don't know how to get them in the page and do the math.

  3. #3
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Rep Power


    Stop and remove all that java code from the JSP.
    Java code should be in helper Java classes and servlets.
    Only use JSPs for displaying data using EL. After that, it will be obvious where you need to do the calculations.

Similar Threads

  1. JDBC and mySQL database trouble
    By ichwar in forum JDBC
    Replies: 17
    Last Post: 08-16-2010, 11:21 PM
  2. Trouble with jtables from a database
    By mitty in forum AWT / Swing
    Replies: 1
    Last Post: 04-20-2010, 03:05 PM
  3. Replies: 2
    Last Post: 02-11-2009, 04:43 AM
  4. database with mysql using the netbeans 6.0
    By kwesiaryee in forum New To Java
    Replies: 2
    Last Post: 05-02-2008, 04:27 AM
  5. MySQL Database and Java
    By shaggymac in forum Advanced Java
    Replies: 1
    Last Post: 05-01-2008, 09:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts