3
* Copyright (C) 2008 Murray Cumming
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License as
7
* published by the Free Software Foundation; either version 2 of the
8
* License, or (at your option) any later version.
10
* This program is distributed in the hope that it will be useful, but
11
* WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
* General Public License for more details.
15
* You should have received a copy of the GNU General Public
16
* License along with this program; if not, write to the
17
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18
* Boston, MA 02111-1307, USA.
21
#include <libgdamm/init.h>
22
#include <glom/libglom/connectionpool.h>
26
main(int argc, char* argv[])
28
Gnome::Gda::init("test", "0.1", argc, argv);
30
Glib::RefPtr<Gnome::Gda::Connection> gdaconnection;
33
//Set the connection details:
34
Glom::ConnectionPool* connection_pool = Glom::ConnectionPool::get_instance();
37
//Set the connection details in the ConnectionPool singleton.
38
//The ConnectionPool will now use these every time it tries to connect.
40
connection_pool->set_database("glom_musiccollection217");
41
connection_pool->set_host("localhost");
42
connection_pool->set_user("murrayc");
43
connection_pool->set_password("murraycpw");
45
connection_pool->set_port(5433);
46
connection_pool->set_try_other_ports(false);
48
connection_pool->set_ready_to_connect(); //Box_WithButtons::connect_to_server() will now attempt the connection-> Shared instances of m_Connection will also be usable.
52
Glom::sharedptr<Glom::SharedConnection> connection;
53
#ifdef GLIBMM_EXCEPTIONS_ENABLED
54
connection = Glom::ConnectionPool::get_and_connect();
56
std::auto_ptr<ExceptionConnection> error;
57
connection = Glom::ConnectionPool::get_and_connect(error);
61
std::cout << "Connected" << std::endl;
63
std::cout << "Connection failed." << std::endl;
65
gdaconnection = connection->get_gda_connection();
67
Glom::ConnectionPool::delete_instance();
70
std::cout << "gdaconnection refcount=" << G_OBJECT(gdaconnection->gobj())->ref_count << std::endl;