Results 1 to 3 of 3
- 04-12-2011, 11:36 PM #1
Member
- Join Date
- Feb 2011
- Posts
- 8
- Rep Power
- 0
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=********"; 15: 16: //Establish Connection 17: Connection cxn = DriverManager.getConnection(cs);
This is the full code on the page.
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.Java Code:<html> <head> <title>Movie Catalog</title> </head> <body> <%@ include file="header.htm" %> <%@ page import="java.sql.*" %> <% //Load driver Class.forName("com.mysql.jdbc.Driver").newInstance(); //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, movie.box, (movie.box/movie.budget) FROM movie"; ResultSet rs = stm.executeQuery(query); %> <h1><FONT COLOR="B22222">Movies Catalog</FONT></h1><br /> <table> <tr> <th>Movie ID</th><th>Title</th><th>Genre</th><th>MPAA</th><th>Release Date</th> <th>Revenue</th><th>ROI</th> </tr> <% while(rs.next()){ %> <tr> <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> </tr> <%}%> </table> <% rs.close(); stm.close(); cxn.close(); %> <br /><br /> <%@ include file="footer.htm" %> </body> </html>Last edited by killasaurus tex; 04-13-2011 at 02:06 AM.
- 04-13-2011, 02:25 AM #2
Member
- Join Date
- Feb 2011
- Posts
- 8
- Rep Power
- 0
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.
- 04-13-2011, 06:39 AM #3
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
Similar Threads
-
JDBC and mySQL database trouble
By ichwar in forum JDBCReplies: 17Last Post: 08-16-2010, 11:21 PM -
Trouble with jtables from a database
By mitty in forum AWT / SwingReplies: 1Last Post: 04-20-2010, 03:05 PM -
How to convert access database to mysql database?
By vrk in forum Advanced JavaReplies: 2Last Post: 02-11-2009, 04:43 AM -
database with mysql using the netbeans 6.0
By kwesiaryee in forum New To JavaReplies: 2Last Post: 05-02-2008, 04:27 AM -
MySQL Database and Java
By shaggymac in forum Advanced JavaReplies: 1Last Post: 05-01-2008, 09:01 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks