pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: John Dunlap <john.dunlap@exceter.com>
To: pgsql-jdbc@postgresql.org
Subject: Re: No suitable driver found
Date: Mon, 27 Jul 2009 11:57:01 -0400
Message-ID: <4A6DCE4D.4010504@exceter.com> (raw)
In-Reply-To: <D960CB61B694CF459DCFB4B0128514C203937E6A@exadv11.host.magwien.gv.at>
References: <4A6B24CC.209@exceter.com>
	<D960CB61B694CF459DCFB4B0128514C203937E6A@exadv11.host.magwien.gv.at>

This is my hibernate configuration (minus my entity definitions). You'll 
notice that the MySQL section has been commented out. If I uncomment the 
mysql config and comment out the postgresql config, hibernate generates 
the database schema perfectly.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd";
<hibernate-configuration>
    <session-factory>
        <property name="hibernate.show_sql">false</property>
        <property name="hibernate.format_sql">false</property>
        <property name="use_sql_comments">false</property>
        <property 
name="hibernate.current_session_context_class">org.hibernate.context.ThreadLocalSessionContext</property>

        <property 
name="hibernate.connection.driver_class">org.postgresql.Driver</property>
        <property 
name="hibernate.connection.url">jdbc:postgresql://localhost:5432/mydatabase</property>
        <property name="hibernate.connection.username">myusername</property>
        <property name="hibernate.connection.password">mypasswrd</property>
        <property 
name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>

        <!--
        <property 
name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property 
name="hibernate.connection.url">jdbc:mysql://localhost:3306/mydatabase</property>
        <property name="hibernate.connection.username">myusername</property>
        <property name="hibernate.connection.password">mypasswrd</property>
        <property 
name="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
        -->
    </session-factory>
</hibernate-configuration>

If I comment out the mysql confg and uncomment the postgresql config, 
the schema generation fails with the following stack trace. As you can 
see, I am fully qualifying the driver class as "org.postgresql.Driver" 
and I can assure you that postgresql-8.3-603.jdbc4.jar is in my 
classpath (I can see it in eclipse under Maven Dependencies).

11:09:45,533  INFO org.hibernate.tool.hbm2ddl.SchemaExport - Running 
hbm2ddl schema export
11:09:45,535  INFO org.hibernate.tool.hbm2ddl.SchemaExport - exporting 
generated schema to database
11:09:45,538  INFO 
org.hibernate.connection.DriverManagerConnectionProvider - Using 
Hibernate built-in connection pool (not for production use!)
11:09:45,538  INFO 
org.hibernate.connection.DriverManagerConnectionProvider - Hibernate 
connection pool size: 20
11:09:45,538  INFO 
org.hibernate.connection.DriverManagerConnectionProvider - autocommit 
mode: false
11:09:45,540  INFO 
org.hibernate.connection.DriverManagerConnectionProvider - using driver: 
org.postgresql.Driver at URL: jdbc:postgresql://localhost:5432/mydatabase
11:09:45,540  INFO 
org.hibernate.connection.DriverManagerConnectionProvider - connection 
properties: {user=myusername, password=****}
11:09:45,555 ERROR org.hibernate.tool.hbm2ddl.SchemaExport - schema 
export unsuccessful
java.sql.SQLException: No suitable driver found for 
jdbc:postgresql://localhost:5432/mydatabase
   at java.sql.DriverManager.getConnection(DriverManager.java:602)
   at java.sql.DriverManager.getConnection(DriverManager.java:154)
   at 
org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:133) 

   at 
org.hibernate.tool.hbm2ddl.ManagedProviderConnectionHelper.prepare(ManagedProviderConnectionHelper.java:52) 

   at 
org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:252)
   at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:211)
   at 
org.codehaus.mojo.hibernate3.exporter.Hbm2DDLExporterMojo.doExecute(Hbm2DDLExporterMojo.java:112) 

   at 
org.codehaus.mojo.hibernate3.HibernateExporterMojo.execute(HibernateExporterMojo.java:152) 

   at 
org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:579) 

   at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:498) 

   at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegmentForProject(DefaultLifecycleExecutor.java:265) 

   at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:191) 

   at 
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:149) 

   at 
org.apache.maven.DefaultMaven.execute_aroundBody0(DefaultMaven.java:223)
   at 
org.apache.maven.DefaultMaven.execute_aroundBody1$advice(DefaultMaven.java:304) 

   at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:1)
   at 
org.apache.maven.embedder.MavenEmbedder.execute_aroundBody2(MavenEmbedder.java:904) 

   at 
org.apache.maven.embedder.MavenEmbedder.execute_aroundBody3$advice(MavenEmbedder.java:304) 

   at org.apache.maven.embedder.MavenEmbedder.execute(MavenEmbedder.java:1)
   at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:176)
   at org.apache.maven.cli.MavenCli.main(MavenCli.java:63)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 

   at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 

   at java.lang.reflect.Method.invoke(Method.java:597)
   at 
org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) 

   at 
org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
   at 
org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:408) 

   at 
org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:351)
   at org.codehaus.classworlds.Launcher.main(Launcher.java:31)

Like I said in my last email. I've done this with many other databases 
in the past and this is the first database I've seen this error with 
(although I've seen a lot of other issues).

Albe Laurenz wrote:
> John Dunlap wrote:
>
>   
>> I've been looking for a solution to this error for a few days now. 
>> Everything I've found says that the problem should be that I have a 
>> malformed url but I've gone over it dozens of times and I don't think 
>> that it's wrong (I wish it was). I'm trying to use hibernate tools to 
>> generate my database schema through the JDBC driver. 
>>
>> I'm getting the following stack trace,
>> java.sql.SQLException: No suitable driver found for 
>> jdbc:postgresql://localhost:5432/mydatabase
>>     at java.sql.DriverManager.getConnection(DriverManager.java:602)
>>     
> [...]
>
> I don't know anything about Hibernate, but this error suggests that
> the system does not know the PostgreSQL JDBC driver.
>
> There are several ways to register it:
> - Use the class org.postgresql.Driver, for example with the statement
>   Class.forName("org.postgresql.Driver");
>
> - Start the Java Virtual Machine with the flag
>   -Djdbc.drivers=org.postgresql.Driver
>
> You'll probably have to figure out how to do that in Hibernate,
> but it should work exactly as with other JDBC drivers.
>
> Yours,
> Laurenz Albe
>   




view thread (7+ messages)  latest in thread

Message-ID: <4A6DCE4D.4010504@exceter.com>
Permalink:  ../4A6DCE4D.4010504@exceter.com/
Also on:    postgresql.org/message-id/4A6DCE4D.4010504@exceter.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: john.dunlap@exceter.com
  Subject: Re: No suitable driver found
  In-Reply-To: <4A6DCE4D.4010504@exceter.com>
  References: <4A6B24CC.209@exceter.com> <D960CB61B694CF459DCFB4B0128514C203937E6A@exadv11.host.magwien.gv.at> <4A6DCE4D.4010504@exceter.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox