cnd
cnd

Reputation: 33784

Nhibernate cfg xml can't connect to Postgres

Test exception is :

Test method DevLair.Tests.GenerateSchema_Fixture.Can_generate_schema> threw exception: NHibernate.HibernateException:

key=value argument incorrect in ConnectionString

Parameter Name : initial catalog ---> System.ArgumentException: key=valuergument incorrect in ConnectionString

hibernate.cfg.xml is :

<?xml version="1.0" encoding="utf-8"?>

<hibernate-configuration  xmlns="urn:nhibernate-configuration-2.2" >
    <session-factory name="NHibernate.Test">
        <property name="connection.driver_class">NHibernate.Driver.NpgsqlDriver</property>
        <property name="connection.connection_string">
            Server=postgres48.1gb.ru;initial catalog=xgb_dlusers;User ID=xgb_dlusers;Password=****;
        </property>
        <property name="dialect">NHibernate.Dialect.PostgreSQLDialect</property>
        <property name="proxyfactory.factory_class">NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu</property>
    </session-factory>
</hibernate-configuration>

what's wrong with initial catalog ?

Upvotes: 1

Views: 2725

Answers (1)

UpTheCreek
UpTheCreek

Reputation: 32391

By the looks of the error, the connection string is invalid.

Heres an example Npgsqldriver connection string:

Server=127.0.0.1;Port=5432;Database=myDataBase;User Id=myUsername;Password=myPassword;

Possible problems with yours:

  • use Database instead of initial catalogue (this is most likely the problem)
  • use User Id instead of User ID (don't know if it's case sensitive)
  • Missing port

Upvotes: 2

Related Questions