환경은 터보리눅스이고, postgres는 리눅스 setting 때 옵션으로 깔았습니다.
jdbc드라이버를 compile할려고 하니 'src/interfaces/jdbc'디렉토리가 없더군요.
그래서 여기 자료실에 가서 'postgressql.jar'을 다운받아
/var/lib/pqsql/jdbc디레토리를 만들고 .bash_profile에 classpath를 잡았습니다.
'CLASSPATH=/var/lib/pgsql/jdbc/postgresql.jar:.'
소스코드인 postJdbcTest.jsp입니다. 좀 봐주십시요.드라이버 로드는 되는데
connection이 안 맺어지더라구요.
System.out.println으로 프린트 해보니
System.out.println("1");은 프린트 되는데,
System.out.println("2");는 안되더라구요...
<%@ page contentType="text/html; charset=EUC-KR" %>
<%@ page language="java" import="java.util.*, java.sql.*, java.io.*" %>
<html>
<head>
<title>:::::포스트그레스 Connection Test:::::</title>
<meta http-equiv="Content-Type" content="text/html; charset=euc-kr">
</head>
<body>
<br>
<%
Connection conn = null;
try{
// Class.forName("org.postgresql.Driver");
DriverManager.registerDriver(new org.postgresql.Driver());
System.out.println("1");
conn = DriverManager.getConnection ("jdbc:postgresql:template1", "kms","kms");
// conn = DriverManager.getConnection("jdbc");
System.out.println("2");
if(conn != null){
out.println("PostgreSql DB Connection Success!!!");
}
if(conn == null){
out.println("PostgreSql DB Connection Failed!!!");
}
conn.close();
// }catch(ClassNotFoundException e) {
// conn.close();
// out.println(e.getMessage());
}catch(SQLException ex){
conn.close();
out.println(ex.getMessage());
}catch(Exception e){
System.out.println("1"+e.getMessage());
}finally{
if(conn != null){
try{
conn.close();
}catch(Exception ex) {}
}
}
%>
</body>
</html>
|