Re: PostgreSQL Connection Problem



On Fri, 2008-03-28 at 11:03 -0500, inbox_pub earthlink net wrote:
> I am trying to use libgnomedbmm to connect to a PostgreSQL database.
> I am using a global ODBC connection with the DSN=playback.
> When I compile, I get no errors.
> However, when I run the program, I get this error message:
>    Data source playback not found in configuration
> 
> I based the code off of the "simple example" in the "Programming with 
> libgnomedbmm" book.
> 
> Here is the code through the connect statement:
> 
> #include <iostream>
> #include <libgnomedbmm.h>
> #include <gtkmm.h>
> 
> int main(int argc, char* argv[])
> {
>         Gtk::Main kit(argc, argv);
>         Gnome::Db::init("playback", "1.0", argc, argv);
> 
>         Glib::RefPtr<Gnome::Gda::Client> client = 
> Gnome::Gda::Client::create();
> 
>         Glib::RefPtr<Gnome::Gda::DataModel> model;
> 
>         // Create a connection to an example SQLite database. The 
> function might
>         // fail, so we have to catch potential exceptions.
> #ifdef GLIBMM_EXCEPTIONS_ENABLED
>         try
>         {
>                 // Glib::RefPtr<Gnome::Gda::Connection> connection = 
> client->open_connection_from_string(\
>                 // "SQLite", "DB_DIR=" LIBGNOMEDB_DATADIR 
> ";DB_NAME=demo_db", "" /* username */, "" /* password */);
>                 // Use PostgreSQL through ODBC instead . . .            
>                 // 
> "ODBC;DRIVER={PostgreSQL};DATABASE=playback;SERVER=localhost;PORT=5432;Uid=joe;Pwd=\0;"
>                 Glib::RefPtr<Gnome::Gda::Connection> connection = 
> client->open_connection("playback","","");
[snip]

You seem to not be calling both open_connection_from_string() and
calling open_connection() instead. The example doesn't do this:
http://www.gtkmm.org/docs/libgnomedbmm-3.0/docs/tutorial/html/ch03s05.html

open_connection() takes a DSN (data source name), but you have not
created any such data source in the configuratoin:
http://www.gtkmm.org/docs/libgdamm-3.0/docs/reference/libgdamm/html/classGnome_1_1Gda_1_1Client.html#27f09fa0145db3e16cc76bd0360faf27

Personally, I just use open_connection_from_string() and ignore the
DSN/config system.

-- 
murrayc murrayc com
www.murrayc.com
www.openismus.com



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]