•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JSP section within the Web Development category of DaniWeb, a massive community of 402,834 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,094 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JSP advertiser: Lunarpages JSP Web Hosting
Views: 626 | Replies: 3
![]() |
•
•
Join Date: Aug 2007
Location: Somewhere between heaven and hell
Posts: 94
Reputation:
Rep Power: 2
Solved Threads: 6
Dear all,
I filter my query select with parameter from previous page.
SQL = "select a.KodePenyanyi, p.NamaPenyanyi, p.WebSite, a.KodeAlbum, a.NamaAlbum, NamaLabel, Tahun, a.Kaset, a.CD, a.CDImport, a.DVD, DaftarLagu, ReviewAlbum FROM masterpenyanyi p inner join masteralbum a on a.KodePenyanyi=p.KodePenyanyi inner join masterlabel on masterlabel.KodeLabel = a.KodeLabel where a.KodeAlbum='" + kodeAlbum + "'";
Result should be like this :
select a.KodePenyanyi, p.NamaPenyanyi, p.WebSite, a.KodeAlbum, a.NamaAlbum, NamaLabel, Tahun, a.Kaset, a.CD, a.CDImport, a.DVD, DaftarLagu, ReviewAlbum FROM masterpenyanyi p inner join masteralbum a on a.KodePenyanyi=p.KodePenyanyi inner join masterlabel on masterlabel.KodeLabel = a.KodeLabel where a.KodeAlbum='SID-001'
but I dont know why JSP gives this result :
select a.KodePenyanyi, p.NamaPenyanyi, p.WebSite, a.KodeAlbum, a.NamaAlbum, NamaLabel, Tahun, a.Kaset, a.CD, a.CDImport, a.DVD, DaftarLagu, ReviewAlbum FROM masterpenyanyi p inner join masteralbum a on a.KodePenyanyi=p.KodePenyanyi inner join masterlabel on masterlabel.KodeLabel = a.KodeLabel where a.KodeAlbum='"000002-0015"'
I filter my query select with parameter from previous page.
SQL = "select a.KodePenyanyi, p.NamaPenyanyi, p.WebSite, a.KodeAlbum, a.NamaAlbum, NamaLabel, Tahun, a.Kaset, a.CD, a.CDImport, a.DVD, DaftarLagu, ReviewAlbum FROM masterpenyanyi p inner join masteralbum a on a.KodePenyanyi=p.KodePenyanyi inner join masterlabel on masterlabel.KodeLabel = a.KodeLabel where a.KodeAlbum='" + kodeAlbum + "'";
Result should be like this :
select a.KodePenyanyi, p.NamaPenyanyi, p.WebSite, a.KodeAlbum, a.NamaAlbum, NamaLabel, Tahun, a.Kaset, a.CD, a.CDImport, a.DVD, DaftarLagu, ReviewAlbum FROM masterpenyanyi p inner join masteralbum a on a.KodePenyanyi=p.KodePenyanyi inner join masterlabel on masterlabel.KodeLabel = a.KodeLabel where a.KodeAlbum='SID-001'
but I dont know why JSP gives this result :
select a.KodePenyanyi, p.NamaPenyanyi, p.WebSite, a.KodeAlbum, a.NamaAlbum, NamaLabel, Tahun, a.Kaset, a.CD, a.CDImport, a.DVD, DaftarLagu, ReviewAlbum FROM masterpenyanyi p inner join masteralbum a on a.KodePenyanyi=p.KodePenyanyi inner join masterlabel on masterlabel.KodeLabel = a.KodeLabel where a.KodeAlbum='"000002-0015"'
<%@ page language="java" import="java.sql.*" %>
<%@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">
<%
ResultSet rst=null;
Statement stmt=null;
Connection cn = null;
try {
Class.forName("com.mysql.jdbc.Driver");
String url;
url = "jdbc:mysql://localhost:3306/tokomusik?user=root&password=root";
cn = DriverManager.getConnection (url);
stmt=cn.createStatement();
String kodeAlbum;
kodeAlbum = request.getParameter("KodeAlbum");
String SQL;
SQL = "select a.KodePenyanyi, p.NamaPenyanyi, p.WebSite, a.KodeAlbum, a.NamaAlbum, NamaLabel, Tahun, a.Kaset, a.CD, a.CDImport, a.DVD, DaftarLagu, ReviewAlbum FROM masterpenyanyi p inner join masteralbum a on a.KodePenyanyi=p.KodePenyanyi inner join masterlabel on masterlabel.KodeLabel = a.KodeLabel where a.KodeAlbum='" + kodeAlbum + "'"; rst=stmt.executeQuery(SQL);
out.println(SQL);
}
catch (SQLException se)
{
out.println(se.toString());
} catch (Exception ex)
{
out.println(ex.toString());
}
%> NEVER NEVER NEVER GIVE UP
•
•
Join Date: Dec 2004
Location: London or Slovakia
Posts: 2,239
Reputation:
Rep Power: 10
Solved Threads: 270
Ouch, do not put database connection in JSP! JSP is for presentation purposes. It is servlet that does logic, which include connection to DB. Also there is nothing worng with JSP (beside that DB connection part) it is your query that is wrong, work correct formula in database and then re-use it in connection
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
If we helped you to solve your problem, answered your question please mark your post as SOLVED.
Publilius Syrus
(~100 BC)
If we helped you to solve your problem, answered your question please mark your post as SOLVED.
•
•
Join Date: Aug 2007
Location: Somewhere between heaven and hell
Posts: 94
Reputation:
Rep Power: 2
Solved Threads: 6
•
•
•
•
Ouch, do not put database connection in JSP! JSP is for presentation purposes. It is servlet that does logic, which include connection to DB. Also there is nothing worng with JSP (beside that DB connection part) it is your query that is wrong, work correct formula in database and then re-use it in connection
Yes, I know my false. I have read these matter in others threads.
I put connection in JSP because I still don't know how to connect it to servlet.
But my problem is in my query select.
Thanks,
Kusno.
NEVER NEVER NEVER GIVE UP
> but I dont know why JSP gives this result :
Maybe because "KodeAlbum" actually contains "000002-0015"? It would be better if you printed out the value of the form field "KodeAlbum" after form submission and made sure it is the same as you want. If yes, then the change is happening somewhere in between the request attribute being set and it's use.
Maybe because "KodeAlbum" actually contains "000002-0015"? It would be better if you printed out the value of the form field "KodeAlbum" after form submission and made sure it is the same as you want. If yes, then the change is happening somewhere in between the request attribute being set and it's use.
"I don't accept change. I don't deserve to live."
"Working a real job is a win if you're lazy, greedy, or unmotivated. If you're average, you fit right in. And if you're above average, the basic terms of employment and premise of the arrangement is against your interests."
"Working a real job is a win if you're lazy, greedy, or unmotivated. If you're average, you fit right in. And if you're above average, the basic terms of employment and premise of the arrangement is against your interests."
![]() |
•
•
•
•
•
•
•
•
DaniWeb JSP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- sql query problem with MS Access and C# (C#)
- SQL query problem with WHERE clause (ASP)
- sql query updating problem (Visual Basic 4 / 5 / 6)
- Please help me out with MySQL query (MySQL)
- query problem (MySQL)
Other Threads in the JSP Forum
- Previous Thread: Online Shopping
- Next Thread: JSP Combobox



Linear Mode