PostgreSQL
La base de données la plus sophistiquée au monde.

Ouverture de session

Navigation

Contactez-nous

Administration du site :
"equipe chez postgresqlfr point org"

Contact presse :
"fr chez postgresql point org"

Contact association :
"bureau chez postgresqlfr point org"

Questions PostgreSQL :
 IRC :
  serveur irc.freenode.net
  canal #postgresqlfr

Recherche

Accéder aux archives

« Octobre 2008  
Lun Mar Mer Jeu Ven Sam Dim
  2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31  

Syndication

Flux XML

Sondage

Quelle est la version de PostgreSQL la plus répandue sur vos serveurs ?
8.3
10%
8.2
42%
8.1
40%
8.0
2%
7.4
6%
7.3 ou antérieure
0%
Nombre de votes: 48

No suitable driver found for jdbc:postgresql://Poweredge/news2

Technique - odbc | No suitable driver found for jdbc:postgresql://Poweredge/news2

Par JFD BCX le 15/02/2007 - 17:02

Je tente désespérément de me connecter à une base de données distante (sous serveur PostgreSql 8.2) depuis une appli Eclipse RCP (Java plugin donc).
Je lève systématiquement l'exception suivante : No suitable driver found for jdbc:postgresql://Poweredge/biochemics
J'ai placé strictement le même code dans une application Java standard (toujours sous Eclipse) et cela marche parfaitement.
A noter que 'Class.forName ("org.postgresql.Driver")' ne fonctionne pas dans ce contexte.

package gui_auto;

import org.eclipse.core.runtime.IPlatformRunnable;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
import java.sql.*;
import java.util.Enumeration;
import java.lang.reflect.*;

public class Application implements IPlatformRunnable {
public Object run(Object args) throws Exception {
Display display = PlatformUI.createDisplay ();

Class CnxClass = null;
/*// The following snippet does'nt work in a extension, only in a regular application !!!
try {
CnxClass = Class.forName ("org.postgresql.Driver");
System.out.println ("Class found (forName) " + CnxClass.toString ());
} catch (ClassNotFoundException e) {
System.err.println ("Class not found (forName) ! " + e.toString ());
}*/

// Try to load the class from ContextClassLoader
Thread t = Thread.currentThread ();
ClassLoader cl = t.getContextClassLoader ();
Class toRun;
try {
toRun = cl.loadClass ("org.postgresql.Driver");
System.out.println ("Class loaded as " + toRun.toString ());

Method [] methods = toRun.getMethods ();
for (int i = 0; i < methods.length; i++)
System.err.println (methods [i].getName () + " function found in " + toRun.toString ());

} catch (ClassNotFoundException e) {
System.err.println ("Class not found (loadClass) ! " + e.toString ());
}
/* // This works fine too...
try {
Driver driver = (Driver) new org.postgresql.Driver ();
//DriverManager.registerDriver (driver); -- Driver recorded twice !!!
} catch (Exception e) {
System.err.println ("Class not found (complex forName) ! " + e.toString ());
} */
// Check available drivers
for (Enumeration wEnum = DriverManager.getDrivers (); wEnum.hasMoreElements() ;) {
System.out.println ("Driver found : " + wEnum.nextElement().toString ());
}

// Try to connect the database
Connection conn = null;
String url;
try {
url = "jdbc:postgresql://Poweredge/biochemics";
conn = DriverManager.getConnection (url, "postgres", "postgres");
} catch (SQLException E) {
System.err.println ("Unable to connect to biochemics database : " + E.toString ());
E.printStackTrace ();
}
... l'exception est générée ici, la trace du programme suit :

Class loaded as class org.postgresql.Driver
acceptsURL function found in class org.postgresql.Driver
getPropertyInfo function found in class org.postgresql.Driver
jdbcCompliant function found in class org.postgresql.Driver
notImplemented function found in class org.postgresql.Driver
setLogLevel function found in class org.postgresql.Driver
getLogLevel function found in class org.postgresql.Driver
makeSSL function found in class org.postgresql.Driver
sslEnabled function found in class org.postgresql.Driver
connect function found in class org.postgresql.Driver
getMajorVersion function found in class org.postgresql.Driver
getMinorVersion function found in class org.postgresql.Driver
getVersion function found in class org.postgresql.Driver
hashCode function found in class org.postgresql.Driver
getClass function found in class org.postgresql.Driver
wait function found in class org.postgresql.Driver
wait function found in class org.postgresql.Driver
wait function found in class org.postgresql.Driver
equals function found in class org.postgresql.Driver
toString function found in class org.postgresql.Driver
notify function found in class org.postgresql.Driver
notifyAll function found in class org.postgresql.Driver
Driver found : sun.jdbc.odbc.JdbcOdbcDriver@d6c16c
Unable to connect to biochemics database : java.sql.SQLException: No suitable driver found for jdbc:postgresql://Poweredge/biochemics
java.sql.SQLException: No suitable driver found for jdbc:postgresql://Poweredge/biochemics
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at gui_auto.Application.run(Application.java:64)
at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:78)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:92)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:68)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.core.launcher.Main.invokeFramework(Main.java:336)
at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
at org.eclipse.core.launcher.Main.run(Main.java:977)
at org.eclipse.core.launcher.Main.main(Main.java:952)

Options d'affichage des commentaires

Sélectionnez la méthode d'affichage des commentaires que vous préférez, puis cliquez sur "Sauvegarder les paramètres" pour activer vos changements.

reponse

lilington/ = 8 DĂ©cembre, 2007 - 14:04

J'ai eu le meme probleme pour le resoudre du mets dans ton repertoire
webcontent/web-inf/lib le fichier .jar du driver et le tour est joue.


© PostgreSQLFr, tous droits rĂ©servĂ©s.
Site déclaré à la CNIL sous le numéro 1074678, conformément à la Loi en vigueur.