PostgreSQL Connection Problem
- From: inbox_pub earthlink net
- To: gtkmm-list gnome org
- Subject: PostgreSQL Connection Problem
- Date: Fri, 28 Mar 2008 11:03:10 -0500
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","","");
model = connection->execute_select_command("SELECT *
FROM game");
}
catch(const Glib::Error& e)
{
std::cerr << e.what() << std::endl;
return 1;
}
#else
// END OF THE PART THAT I HAVE CHANGED
QUESTION: What do I have wrong and how do I fix it?
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]