jsp 와 db를 연동하여 우편번호 검색을 하려고 합니다.근데 잘 안되네요.꼭 봐주세요. db 연동 my-sql 나비캣

killname의 이미지

일단 검색이랑 시뮬은 되는데 조회 버튼을 누르면 제 서버에 디비를 조사해야 하는데 왜 안되는지 모르겠네여.ㅠ
<%@ page import="java.sql.*,javax.sql.DataSource,java.util.Properties, javax.naming.*" %>
<%@ page contentType="text/html;charset=euc-kr"%>
<%
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Cache-Control", "no-store");
response.setHeader("pragma", "no-cache");
%>

<head>
<style>
	A:link {text-decoration:none;color:#5f5f5f}
	A:hover{text-decoration:yes;color:#038afd}
	A:visited {text-decoration:none;color:#5f5f5f}
	td{font-size:10pt}
</style> 
<script language="javascript">
<!--
function fnReturnToMain(zipcode,juso)
{
    var rgParam = new Array;
    rgParam[0] = zipcode;
    rgParam[1] = juso;
    top.window.returnValue = rgParam;
    window.close();
    return;
}
//-->
</script>
</head>
<%
Connection conn = null;
ResultSet rset = null;
Statement stmt = null;
%>
<body text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" bgcolor="#FFFFFF">
<form name="thisPage" method="post">
<table>
	<tr><td>
		<table style="BORDER-COLLAPSE: collapse" borderColor=#b4c7d4 cellSpacing=1 align=center border=1>
  			<tr bgcolor="D3D2CA" align="center">
				<td width="70">우편번호</td>
				<td width="80">시도</td>
				<td width="80">구군</td>
				<td></td>
				<td width="80">번지</td>
			</tr>
<%
try
{
	// Mysql DB 연결 정보
	String DB_URL = "jdbc:mysql://localhost:3306/test";
	String DB_USER = "root";
	String DB_PASSWORD= "";
 
	Class.forName("org.gjt.mm.mysql.Driver");
	conn = DriverManager.getConnection(DB_URL, DB_USER, DB_PASSWORD);
	stmt = conn.createStatement();
 
	String strZipcode = "", strJuso = "";
	String strFlag = request.getParameter("reqflag");		// 조회 조건
	String strVal = request.getParameter("reqVal");	// 조회 입력값
	String query = "SELECT * FROM postcode, "+
	                       "sido, "+
	                       "gugun, "+
	                       "dong, "+
	                       "bunji "+
                   "FROM postcode ";
	if (strFlag.equals("1")){			// 시도로 조회
			query += "WHERE sido like '%"+strVal+"%' ";
	} else if (strFlag.equals("2")){	// 구군으로 조회
		query += "WHERE gugun like '%"+strVal+"%' ";
	} else if (strFlag.equals("3")){	// 동으로 조회
		query += "WHERE dong like '%"+strVal+"%' ";
	}
	query += "ORDER BY sido, gugun, dong asc";
	rset = stmt.executeQuery(query);
	while(rset.next()){
		// 우편번호 style 선택 (100-754 or 100754)
		//strZipcode = rset.getString(1);
		strZipcode = rset.getString(1).substring(0,3) +"-"+ rset.getString(1).substring(3,6);
		strJuso = (new String(rset.getString(2).getBytes("8859_1"),"EUC-KR")) +" "+ (new String(rset.getString(3).getBytes("8859_1"),"EUC-KR")) +" "+ (new String(rset.getString(4).getBytes("8859_1"),"EUC-KR")) +" "+ (new String(rset.getString(5).getBytes("8859_1"),"EUC-KR"));
%>		
			<tr bgcolor="#F6F6F6" style="cursor:hand" onClick="javascript:fnReturnToMain('<%=strZipcode%>','<%=strJuso%>')" onMouseOver=this.style.backgroundColor="#E8EAFE" onMouseOut=this.style.backgroundColor=''>
				<td align="center"><%=rset.getString(1) %></td>
				<td align="center"><%=new String(rset.getString(2).getBytes("8859_1"),"EUC-KR") %></td>
				<td align="center"><%=new String(rset.getString(3).getBytes("8859_1"),"EUC-KR")%></td>
				<td align="center"><%=new String(rset.getString(4).getBytes("8859_1"),"EUC-KR")%></td>
				<td align="center"><%=new String(rset.getString(5).getBytes("8859_1"),"EUC-KR")%></td>
			</tr>
<%
	}
%>
		</table>
	</td></tr>
</table>
</form>
</body>

<%
}catch(Exception e)
{
e.printStackTrace();
}finally{
try{ rset.close(); stmt.close(); conn.close(); } catch(Exception ex){}
}
%>

소스는 이거구여 나비캣 "jdbc:mysql://localhost:3306/test"; < test 테이블에 sql 을 넣었습니다.근데 돌리질 못하네요.ㅠ

답변점 부탁드립니다.^;

june의 이미지

에러 메시지 뿌려 주세요~~~~~
========================
커피는 블랙이나 설탕만..

커피는 블랙이나 설탕만..

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.