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"'
<%@ 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;
[B]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 + "'";[/B] rst=stmt.executeQuery(SQL);
out.println(SQL);
}
catch (SQLException se)
{
out.println(se.toString());
} catch (Exception ex)
{
out.println(ex.toString());
}
%>