| | |
Problem in netbeans with mysql query.
Please support our JSP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Sep 2007
Posts: 23
Reputation:
Solved Threads: 0
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:
But in context to this entire code i the product_type won't show, it is just a blank field.
When i change
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.
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:
JSP Syntax (Toggle Plain Text)
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 ______ id name type 1 bla blah
JSP Syntax (Toggle Plain Text)
<%-- Document : response Created on : 4.08.2008, 13:40:55 Author : kohuke --%> <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <%@taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%> <sql:query var="varaderida" maxRows="1" dataSource="jdbc/varad"> 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}"/> </sql:query> <c:set var="varader" scope="request" value="${varaderida.rows[0]}"/> <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title> ${varader.name}</title> </head> <body> <table border="0"> <thead> <tr> <th colspan="2">Vara: ${varader.property}</th> </tr> </thead> <tbody> <tr> <td><strong>ID: </strong></td> <td>${varader.property}</td> </tr> <tr> <td><strong>Nimi: </strong></td> <td>${varader.name} </td> </tr> <tr> <td><strong>Liik: </strong></td> <td>${varader.property_type} </td> </tr> </tbody> </table> </body> </html>
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}"/>
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.
•
•
Join Date: Sep 2007
Posts: 23
Reputation:
Solved Threads: 0
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.
This is how the context.xml looks like:
and this how the web.xml looks like
Also i will show you the catalin.log file contest after i have run the project.
JSP Syntax (Toggle Plain Text)
7.08.2008 8:50:10 org.apache.catalina.core.AprLifecycleListener init 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 7.08.2008 8:50:10 org.apache.coyote.http11.Http11Protocol init INFO: Initializing Coyote HTTP/1.1 on http-8084 7.08.2008 8:50:10 org.apache.catalina.startup.Catalina load INFO: Initialization processed in 500 ms 7.08.2008 8:50:10 org.apache.catalina.core.StandardService start INFO: Starting service Catalina 7.08.2008 8:50:10 org.apache.catalina.core.StandardEngine start INFO: Starting Servlet Engine: Apache Tomcat/6.0.16 7.08.2008 8:50:10 org.apache.coyote.http11.Http11Protocol start INFO: Starting Coyote HTTP/1.1 on http-8084 7.08.2008 8:50:10 org.apache.jk.common.ChannelSocket init INFO: JK: ajp13 listening on /0.0.0.0:8009 7.08.2008 8:50:10 org.apache.jk.server.JkMain start INFO: Jk running ID=0 time=0/31 config=null 7.08.2008 8:50:10 org.apache.catalina.startup.Catalina start INFO: Server startup in 387 ms 7.08.2008 8:50:22 org.apache.coyote.http11.Http11Protocol pause INFO: Pausing Coyote HTTP/1.1 on http-8084 7.08.2008 8:50:23 org.apache.catalina.core.StandardService stop INFO: Stopping service Catalina 7.08.2008 8:50:23 org.apache.coyote.http11.Http11Protocol destroy INFO: Stopping Coyote HTTP/1.1 on http-8084 7.08.2008 8:50:26 org.apache.catalina.core.AprLifecycleListener init 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 7.08.2008 8:50:26 org.apache.coyote.http11.Http11Protocol init INFO: Initializing Coyote HTTP/1.1 on http-8084 7.08.2008 8:50:26 org.apache.catalina.startup.Catalina load INFO: Initialization processed in 478 ms 7.08.2008 8:50:27 org.apache.catalina.core.StandardService start INFO: Starting service Catalina 7.08.2008 8:50:27 org.apache.catalina.core.StandardEngine start INFO: Starting Servlet Engine: Apache Tomcat/6.0.16 7.08.2008 8:50:27 org.apache.coyote.http11.Http11Protocol start INFO: Starting Coyote HTTP/1.1 on http-8084 7.08.2008 8:50:27 org.apache.jk.common.ChannelSocket init INFO: JK: ajp13 listening on /0.0.0.0:8009 7.08.2008 8:50:27 org.apache.jk.server.JkMain start INFO: Jk running ID=0 time=0/31 config=null 7.08.2008 8:50:27 org.apache.catalina.startup.Catalina start INFO: Server startup in 428 ms 7.08.2008 8:50:27 org.apache.catalina.core.StandardContext start INFO: Container org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/Varad1] has already been started
This is how the context.xml looks like:
JSP Syntax (Toggle Plain Text)
<?xml version="1.0" encoding="UTF-8"?> <Context path="/Varad1"> <Resource name="jdbc/varad" auth="Container" type="javax.sql.DataSource" maxActive="100" maxIdle="30" maxWait="10000" username="root" password="******" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/varad"/> </Context>
and this how the web.xml looks like
JSP Syntax (Toggle Plain Text)
<?xml version="1.0" encoding="UTF-8"?> <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"> <session-config> <session-timeout> 30 </session-timeout> </session-config> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <resource-ref> <description>jdbc:mysql://localhost:3306/varad</description> <res-ref-name>jdbc/varad</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> <res-sharing-scope>Shareable</res-sharing-scope> </resource-ref> </web-app>
![]() |
Similar Threads
Other Threads in the JSP Forum
- Previous Thread: Session problem in IE
- Next Thread: How to pass variable from Mysql to Jsp
Views: 2439 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for JSP
apache array backbutton combobox comma connection csv database development directorystructure dropdownlist dynamicpagetitles eclipse frames glassfish ie8 imagetodatabse imageupload integer internet java javaee javascript jsf jsp jsppagetitles levels mvc2 mvcmodel2 mysql netbeans network parameters passing ping printinserverinsteadofclient project read redirect request.getparameter response seperated servlet servletdopost()readxml sessions software sql ssl state_saving_method stocks sun tomcat tutorial update values video web write





