[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [linux] jdbc
Il ya qq erreurs dans la doc...
D'abord le fichier .jar, il ne s'appele pas postgresql.jar, tu le trouveras normalement sous /usr/share/pgsql
export CLASSPATH=/usr/share/pgsql/jdbc7.1.1.2.jar:.
(suivant la version)
2. code exemple (qui marche !!!)
import java.util.*;
import java.sql.*;
public class A {
Connection Con;
A() {
try {
Class.forName("org.postgresql.Driver");
Con=DriverManager.getConnection("jdbc:postgresql:database","user"
,"");
} catch(Exception E) {
System.out.println(E.toString());
}
}
void Get() {
try {
Statement Sql=Con.createStatement();
ResultSet rs=Sql.executeQuery("select column from table");
while (rs.next()) {
System.out.println("Column = "+rs.getString(1));
}
}
catch(Exception E) {
System.out.println(E.toString());
}
}
public static void main (String[] args)
{
A z=new A();
z.Get();
}
}
On Sun, 31 Mar 2002 21:28:33 +0200
daniel <daniel@12move.be> wrote:
> Salut tout le monde
>
> qlq'un a-t-il deja utilise le jdbc de postgresql ?
> j'ai instal. postgresql 7.1.... via des rpm avec tous les modules lib
> ... etc
> quand je veux test. les programmes de demo, il y a toujour l'erreur
> (cannot find type "org/postgresql/statement")
> je ne sais pas ce qui manque encore pour que cela fonctionne !
> de plus dans la doc ils disent qu'il faut un CLASSPATH=un
> chemin/postgresql.jar, et je trouve pas ce fichier (postgresql.jar) ?
> je fais quoi pour que sa marche
>
> d'avance un grand merci
>
> daniel
>
> _______________________________________________
> Linux Mailing List
> Archives: http://www.unixtech.be/mailman/listinfo/linux
_______________________________________________
Linux Mailing List
Archives: http://www.unixtech.be/mailman/listinfo/linux