Ŭ·¡½ºÆнº¿¡ ¹°·Ð Æ÷ÇԵǾî ÀÖ½À´Ï´Ù...[¼Ò½ºÃ·ºÎ]


[ ´ÙÀ½ ±Ûµé ] [ À̾ ±Û¿Ã¸®±â(´äÇϱâ) ] [ ÀÚ¹Ù ¹¯°í ´äÇϱâ ]

±Û¾´ÀÌ :¹ÚÁ¾¿± 1999³â 1¿ù 17ÀÏ 19:55:41

In Reply to: Ŭ·¡½º Æнº posted by ³²Áظð on 1999³â 1¿ù 17ÀÏ 13:41:41:

[colorface@cf work]$ echo $CLASSPATH
.:/usr/local/jdk117/lib/classes.zip:/usr/local/jdk117/lib/postgresql.jar
postgres ¼Ò½ºµð·ºÅ丮¿¡¼­ »ý¼ºÈÄ Á¦°¡ º¹»çÇصР°Ì´Ï´Ù...



Âü°í·Î ¼Ò½º ¿Ã¸³´Ï´Ù...


import java.sql.*;


public class testdb {


public static void main(String args[]) {


String url = "jdbc:postgresql://localhost:5432/test";
Connection con;


String query = "select * from table1";


Statement stmt;


try {
Class.forName("postgresql.Driver");
}
catch(java.lang.ClassNotFoundException e) {
System.err.println("Class Not Found Exception : ");
System.err.println(e.getMessage());
}


try {
con = DriverManager.getConnection(url, "postgres", "postgres¾ÏÈ£");
stmt = con.createStatement();


ResultSet rs = stmt.executeQuery(query);


while(rs.next()) {
int num = rs.getInt("id_number");
String name = rs.getString("name");


System.out.println("id : " + num + " -- name : " + name);
}


stmt.close();
con.close();
}
catch(SQLException sqlexcep) {
System.err.println("SQL Exception " + sqlexcep.getMessage());
}
}
}


°á°ú :
[root@cf work]# java testdb
Class Not Found Exception :
postgresql.Driver
SQL Exception No suitable driver



String url = "jdbc:postgresql:test"; ¿Í
String url = "jdbc:postgresql://localhost:5432/test";
¸ðµÎ °°Àº °á°ú°¡ ³ª¿É´Ï´Ù...


´ÙÀ½ ±Ûµé:



À̾ ±Û¿Ã¸®±â(´äÇϱâ)

À̸§:
E-Mail:
Á¦¸ñ:
³»¿ë:
HTML ÅÂ±× Æ÷ÇÔ ¿©ºÎ: HTML ¹®¼­ÀÏ °æ¿ì üũ
°ü·Ã URL(¼±ÅÃ):
URL Á¦¸ñ(¼±ÅÃ):
°ü·Ã À̹ÌÁö URL:


[ ´ÙÀ½ ±Ûµé ] [ À̾ ±Û¿Ã¸®±â(´äÇϱâ) ] [ ÀÚ¹Ù ¹¯°í ´äÇϱâ ]