Servlet에 관한 질문:linux에서 servlet돌려보신분..


[ 다음 글들 ] [ 이어서 글올리기(답하기) ] [ 자바 묻고 답하기 ]

글쓴이 :손준형 2000년 3월 03일 15:29:32

안녕하세요 손준형입니다.
Linux Apache Web server(Jserv module)+JSDK2.0+JDK1.2+PostgreSQL
->이런 환경에서 Sevlet을 test중인데, error log file을 보니까 JDBC driver loading Error....만 계속뜨네요! 어째서일까요?(제가 DB쪽은 꽝이라..)


여기부터는 문제의 Servlet중 Database Class의 소스입니다.
------------------------------------------------------
import java.sql.*;
import java.util.*;


// 데이터베이스 초기화
public class Database
{
String dbName = "BBS";
String postgreSQLDriver = "postgresql.Driver";
String postgreSQLURL =
"jdbc:postgresql:" + dbName ;

String user = "webmaster";
String password = "citech";
Properties props = null;

public static Connection con = null;
Statement stmt = null;

public Database()
{
try
{
props = new Properties();
props.put( "user" , "webmaster" );
props.put( "password" , "citech" );
Class.forName( "postgresql.Driver" );
con = DriverManager.getConnection( "jdbc:postgresql:" + dbName , props );
if( con == null )
{
System.out.println("DEBUG >> class Database : Constructor ==> con is null " );
}
else
System.out.println("DEBUG >> class Database : Constructor ==> con is NOT null " );
}
catch( Exception e)
{
System.err.println("JDBC driver loading Error....");
}

}

public static Connection getConnection()
{
try
{
if( con == null )
{
con = DriverManager.getConnection( "jdbc:postgresql:");//제가 알기로는 getConnection( "jdbc:postgresql:" + dbName)이게 맞을것 같은데 ,이렇게하면 dbName이 nonstatic variable이라는 error가 뜨는군요.....
}
}
catch( SQLException e)
{
System.err.println( "DEBUG>> class Database:getConnection() > Exception = " + e.toString() + " occurred" );
}

return con;
}

public static Statement getStatement()
{
Statement temp = null;
try
{
temp = con.createStatement();
}
catch( SQLException e)
{
System.err.println("class Database : SQLException occured...");
}

return temp;
}

public static PreparedStatement getPreparedStatement( String query )
{
PreparedStatement temp = null;

try
{
temp = con.prepareStatement( query );
}
catch( SQLException e )
{
System.err.println("DEBUG>> class Database: getPreparedStatement > SQLException occured.." );
}

return temp;
}

public static void close()
{
try
{
if( con != null )
con.close();
}
catch( SQLException e)
{
System.err.println("DEBUG>> class Database: close() > SQLException occurred..." );
}
}

}









다음 글들:



이어서 글올리기(답하기)

이름:
E-Mail:
제목:
내용:
HTML 태그 포함 여부: HTML 문서일 경우 체크
관련 URL(선택):
URL 제목(선택):
관련 이미지 URL:


[ 다음 글들 ] [ 이어서 글올리기(답하기) ] [ 자바 묻고 답하기 ]