Problem in netbeans with mysql query.

Thread Solved

Join Date: Sep 2007
Posts: 23
Reputation: kohuke is an unknown quantity at this point 
Solved Threads: 0
kohuke kohuke is offline Offline
Newbie Poster

Problem in netbeans with mysql query.

 
0
  #1
Aug 5th, 2008
Hi,
Well to start od i decided to learn how to create jsp pages and finally finish my project. So i used the netbeans tutorial for making jsp pages. The sample worked fine, but when i wanted ti retrieve information from my own database it do not work like it suppose to be.
The entire point of this code is as follows:
From index.jsp i select a product
Then i'm directed to response page which shows the info of the selected product
It should display product id, name, product_type's name.

But it does not do so. It shows nicely the product id, name, but not the product_type's name. It just shows this field as empty. Product_type is also a foreign key in product table.
When i run this query in mysql database i get the result which i want:
  1. SELECT property.property, property.name AS name, property_type.name AS property_type, property_type.description AS description FROM property, property_type WHERE property.property_type=property_type.property_type
  2. ______
  3. id name type
  4. 1 bla blah
But in context to this entire code i the product_type won't show, it is just a blank field.
  1. <%--
  2. Document : response
  3. Created on : 4.08.2008, 13:40:55
  4. Author : kohuke
  5. --%>
  6. <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
  7. <%@taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
  8. <sql:query var="varaderida" maxRows="1" dataSource="jdbc/varad">
  9. SELECT property.property, property.name AS name, property_type.name AS property_type,
  10. property_type.description AS description
  11. FROM property, property_type
  12. WHERE property.property_type=property_type.property_type AND
  13. property.property = ? <sql:param value="${param.property}"/>
  14. </sql:query>
  15. <c:set var="varader" scope="request" value="${varaderida.rows[0]}"/>
  16. <%@page contentType="text/html" pageEncoding="UTF-8"%>
  17. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  18. "http://www.w3.org/TR/html4/loose.dtd">
  19.  
  20. <html>
  21. <head>
  22. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  23. <title> ${varader.name}</title>
  24. </head>
  25. <body>
  26. <table border="0">
  27. <thead>
  28. <tr>
  29. <th colspan="2">Vara: ${varader.property}</th>
  30. </tr>
  31. </thead>
  32. <tbody>
  33. <tr>
  34. <td><strong>ID: </strong></td>
  35. <td>${varader.property}</td>
  36. </tr>
  37. <tr>
  38. <td><strong>Nimi: </strong></td>
  39. <td>${varader.name}
  40. </td>
  41. </tr>
  42. <tr>
  43. <td><strong>Liik: </strong></td>
  44. <td>${varader.property_type}
  45. </td>
  46. </tr>
  47. </tbody>
  48. </table>
  49. </body>
  50. </html>
When i change
SELECT property.property, property.name AS name, property_type.name AS property_type,
    property_type.description AS description
    FROM property, property_type
    WHERE property.property_type=property_type.property_type AND 
    property.property = ? <sql:param value="${param.property}"/>
property_type.name to property.property_type (That means i'll just display the foreign key, not the name value which the foreign key should be related to...) it shows the spesific value as a number which it should do.

Can you someone please give me tip what should i do to fix this problem. Of course i can leave it like this, but then again it will be very unfair to the "end user" who has to guess what the numbers mean.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 23
Reputation: kohuke is an unknown quantity at this point 
Solved Threads: 0
kohuke kohuke is offline Offline
Newbie Poster

Re: Problem in netbeans with mysql query.

 
0
  #2
Aug 7th, 2008
I forgot to mention that i'm using the latest version of Mysql (5.0), Netbeans 6.1 and Tomcat 6. something.
Also i will show you the catalin.log file contest after i have run the project.
  1. 7.08.2008 8:50:10 org.apache.catalina.core.AprLifecycleListener init
  2. INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.6.0_06\bin;.;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Common Files\Ulead Systems\MPEG;C:\Program Files\ZipGenius 6\;C:\Program Files\Rational\common;C:\Program Files\WinSCP\;C:\Program Files\Intel\DMIX;C:\Program Files\MySQL\MySQL Server 5.0\bin
  3. 7.08.2008 8:50:10 org.apache.coyote.http11.Http11Protocol init
  4. INFO: Initializing Coyote HTTP/1.1 on http-8084
  5. 7.08.2008 8:50:10 org.apache.catalina.startup.Catalina load
  6. INFO: Initialization processed in 500 ms
  7. 7.08.2008 8:50:10 org.apache.catalina.core.StandardService start
  8. INFO: Starting service Catalina
  9. 7.08.2008 8:50:10 org.apache.catalina.core.StandardEngine start
  10. INFO: Starting Servlet Engine: Apache Tomcat/6.0.16
  11. 7.08.2008 8:50:10 org.apache.coyote.http11.Http11Protocol start
  12. INFO: Starting Coyote HTTP/1.1 on http-8084
  13. 7.08.2008 8:50:10 org.apache.jk.common.ChannelSocket init
  14. INFO: JK: ajp13 listening on /0.0.0.0:8009
  15. 7.08.2008 8:50:10 org.apache.jk.server.JkMain start
  16. INFO: Jk running ID=0 time=0/31 config=null
  17. 7.08.2008 8:50:10 org.apache.catalina.startup.Catalina start
  18. INFO: Server startup in 387 ms
  19. 7.08.2008 8:50:22 org.apache.coyote.http11.Http11Protocol pause
  20. INFO: Pausing Coyote HTTP/1.1 on http-8084
  21. 7.08.2008 8:50:23 org.apache.catalina.core.StandardService stop
  22. INFO: Stopping service Catalina
  23. 7.08.2008 8:50:23 org.apache.coyote.http11.Http11Protocol destroy
  24. INFO: Stopping Coyote HTTP/1.1 on http-8084
  25. 7.08.2008 8:50:26 org.apache.catalina.core.AprLifecycleListener init
  26. INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.6.0_06\bin;.;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Common Files\Ulead Systems\MPEG;C:\Program Files\ZipGenius 6\;C:\Program Files\Rational\common;C:\Program Files\WinSCP\;C:\Program Files\Intel\DMIX;C:\Program Files\MySQL\MySQL Server 5.0\bin
  27. 7.08.2008 8:50:26 org.apache.coyote.http11.Http11Protocol init
  28. INFO: Initializing Coyote HTTP/1.1 on http-8084
  29. 7.08.2008 8:50:26 org.apache.catalina.startup.Catalina load
  30. INFO: Initialization processed in 478 ms
  31. 7.08.2008 8:50:27 org.apache.catalina.core.StandardService start
  32. INFO: Starting service Catalina
  33. 7.08.2008 8:50:27 org.apache.catalina.core.StandardEngine start
  34. INFO: Starting Servlet Engine: Apache Tomcat/6.0.16
  35. 7.08.2008 8:50:27 org.apache.coyote.http11.Http11Protocol start
  36. INFO: Starting Coyote HTTP/1.1 on http-8084
  37. 7.08.2008 8:50:27 org.apache.jk.common.ChannelSocket init
  38. INFO: JK: ajp13 listening on /0.0.0.0:8009
  39. 7.08.2008 8:50:27 org.apache.jk.server.JkMain start
  40. INFO: Jk running ID=0 time=0/31 config=null
  41. 7.08.2008 8:50:27 org.apache.catalina.startup.Catalina start
  42. INFO: Server startup in 428 ms
  43. 7.08.2008 8:50:27 org.apache.catalina.core.StandardContext start
  44. INFO: Container org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/Varad1] has already been started

This is how the context.xml looks like:
  1. <?xml version="1.0" encoding="UTF-8"?>
  2.  
  3. <Context path="/Varad1">
  4. <Resource name="jdbc/varad" auth="Container" type="javax.sql.DataSource"
  5. maxActive="100" maxIdle="30" maxWait="10000"
  6. username="root" password="******" driverClassName="com.mysql.jdbc.Driver"
  7. url="jdbc:mysql://localhost:3306/varad"/>
  8. </Context>

and this how the web.xml looks like
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
  3. <session-config>
  4. <session-timeout>
  5. 30
  6. </session-timeout>
  7. </session-config>
  8. <welcome-file-list>
  9. <welcome-file>index.jsp</welcome-file>
  10. </welcome-file-list>
  11. <resource-ref>
  12. <description>jdbc:mysql://localhost:3306/varad</description>
  13. <res-ref-name>jdbc/varad</res-ref-name>
  14. <res-type>javax.sql.DataSource</res-type>
  15. <res-auth>Container</res-auth>
  16. <res-sharing-scope>Shareable</res-sharing-scope>
  17. </resource-ref>
  18. </web-app>
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 23
Reputation: kohuke is an unknown quantity at this point 
Solved Threads: 0
kohuke kohuke is offline Offline
Newbie Poster

Re: Problem in netbeans with mysql query.

 
0
  #3
Aug 21st, 2008
SOLVED.

The database was not persistant
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 2442 | Replies: 2
Thread Tools Search this Thread



Tag cloud for JSP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC