Configuring Hibernate for PostgreSQL Access Over Unix Socket With JDBC

Hello,

I hope it is appropriate to send this question to this address. If not, kindly redirect me.

I am trying to configure Hibernate to use a Unix socket connection to my local PostgreSQL installation. I have referred to this doc:
https://jdbc.postgresql.org/documentation/head/connect.html#connection-parameters

and have been trying entries in hibernate.cfg.xml along these lines:

jdbc:postgresql:kokodoko?socketFactory=org.newsclub.net.unix.socketfactory.PostgresqlAFUNIXSocketFactory&socketFactoryArg=/var/run/postgresql/.s.PGSQL.5432

The XML validator in Eclipse is flagging this error:

The reference to entity "socketFactoryArg" must end with the ';' delimiter.

(Of course I have tried many variations such as inserting semicolons in various places, quoting the argument, using square brackets and so on.)

If I ignore the error and try to use config file I get this error:

{
ā€œerrorā€: {
ā€œerrorsā€: [
{
ā€œdomainā€: ā€œglobalā€,
ā€œreasonā€: ā€œbackendErrorā€,
ā€œmessageā€: ā€œorg.hibernate.internal.util.config.ConfigurationException: Unable to perform unmarshalling at line number 0 and column 0 in RESOURCE hibernate.cfg.xml. Message: nullā€
}
],
ā€œcodeā€: 503,
ā€œmessageā€: ā€œorg.hibernate.internal.util.config.ConfigurationException: Unable to perform unmarshalling at line number 0 and column 0 in RESOURCE hibernate.cfg.xml. Message: nullā€
}
}

which I take to mean that the config file is unusable.

Is what I am trying to do (Hibernate, JDBC, PostgreSQL, hibernate.cfg.xml, Unix socket) possible? If so, kindly give me some guidance. If not, can you suggest a different approach that uses a Unix socket?

I am posting a similar request on the PostgreSql forum.

Thanks very much.

-Dan

Try replacing ā€˜&ā€™ with ā€˜&ā€™ & has a special meaning in XML (entity reference).

Best regards Jens

1 Like

Jens, I just noticed that I did not thank you for this suggestion. Thanks very much. -Dan