You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Harald Wehr <hw...@hs-harz.de> on 2003/12/12 09:16:31 UTC
ClassCastException for Postgres datasource in Generator
In one of our Generators we want to use Postgres as Datasource. In
web.xml we added the postgres driver this way:
<init-param>
<param-name>load-class</param-name>
<param-value>
org.postgresql.Driver
</param-value>
</init-param>
In cocoon.xconf we added the parameters for the connection:
<datasources>
<jdbc name="vrgis">
<pool-controller max="10" min="5"/>
<dburl>jdbc:postgresql://192.168.9.2/vrgis</dburl>
<user>vrgis</user>
<password>sigrv</password>
</jdbc>
</datasources>
In our Generator we implemented the Interface Composable with this method:
public void compose(ComponentManager manager) throws ComponentException {
ComponentSelector selector = (ComponentSelector)
manager.lookup(DataSourceComponent.ROLE+"Selector");
this.datasource = (DataSourceComponent) selector.select("vrgis");
}
Wenn we try to use the datasource in the generate-method we get a
ClassCastException.
--schnipp
Connection conn = datasource.getConnection();
System.out.println(conn);
((Jdbc3Connection)conn).addDataType("geometry","org.postgis.PGgeometry");
((Jdbc3Connection)conn).addDataType("MultiLineString","org.postgis.MultiLineString");
--schnipp
The exception occurs when we try to cast the Connection. When we build
the connection ourself everything is working fine:
Class.forName("org.postgresql.Driver");
String url = "jdbc:postgresql://192.168.9.2/vrgis";
Connection conn = DriverManager.getConnection(url, dbuser, dbpass);
((Jdbc3Connection)conn).addDataType("geometry","org.postgis.PGgeometry");
((Jdbc3Connection)conn).addDataType("MultiLineString","org.postgis.MultiLineString");
System.out.println(conn);
In both ways the System.outs give:
org.postgresql.jdbc3.Jdbc3Connection
Do you have any hints, whats happening here? We are using Cocoon 2.1.3
on Suse Linux 8.1. We tested several postgres-driver version, but that
didn't help out here.
Harald
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: ClassCastException for Postgres datasource in Generator
Posted by Harald Wehr <hw...@hs-harz.de>.
Antonio Gallardo wrote:
> The default postgres port is 5432, after any changes on the postgres
> config, please restart the dbengine.
>
> So in order to connect you need:
>
> <dburl>jdbc:postgresql://192.168.9.2:5432/vrgis</dburl>
>
This did not solve the problem. The connection is established with or
without mentioning the port as this is the default port for postgres.
We _get_ a connection for this datasource. But it seems to be a
different one than the connection we get from our manual initialization.
Harald
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: ClassCastException for Postgres datasource in Generator
Posted by Antonio Gallardo <ag...@agsoftware.dnsalias.com>.
The default postgres port is 5432, after any changes on the postgres
config, please restart the dbengine.
So in order to connect you need:
<dburl>jdbc:postgresql://192.168.9.2:5432/vrgis</dburl>
Best Regards,
Antonio Gallardo
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org