I can't write in korean right now -_-;
1. download jdbc driver from here.
2. Simply you should put the driver in $CATALINA_HOME/webapps/ROOT/WEB-INF/lib.
3. restart your tomcat.
I'll show you simple jsp code.
<%@
page language="java"
contentType="text/html;charset=EUC-KR"
import="java.sql.*"
%>
<%
try{
String url = "jdbc:postgresql://localhost/databasename";
String usr = "userid";
String pwd = "passwd";
Class.forName("org.postgresql.Driver");
Connection conn = DriverManager.getConnection(url, usr, pwd);
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("query made by you");
while(rs.next())
{
out.println(rs.getRow());
out.println("<br>");
out.println(rs.getString("uid"));
}
rs.close();
stmt.close();
conn.close();
} catch (Exception e) {
out.println(e);
}
%>
'프로그래밍 > 웹 프로그래밍' 카테고리의 다른 글
struts + iBATIS + DBCP 사용하기 (0) | 2007.08.27 |
---|---|
[JSP] 날짜 포멧에 맞추어 가져오기 (0) | 2007.07.19 |
[JSP] ResultSet에서 empty set (0) | 2007.03.31 |
[ASP] 자기자신 페이지 이름 (0) | 2007.03.31 |
댓글