Connecting to PostgreSQL database server
Remote connection
For security reasons, we do not allow third party software to connect to the PostgreSQL server, unless the user is a client, who has requested his static IP address to be added to authorised users list. If you would like to be added to the list, please contact the Technical Support team with your database name and static IP, which you will use to connect from.
Server hosting: pgsql.yourdomainname
To connect to the server, you can use either a command line PostgreSQL software, or a graphical interface pgAdmin .
Script Connection
You can use 4 languages to connect to the Pgsql server. ASP, Java, PHP, Python and CGI/Perl. Please find appropriate sample code for your development below.
Java
//ensure that the driver is loaded
Class.forName("org.postgresql.Driver").newInstance();
Connection conn = null;
String connectionString = "jdbc:postgresql://pgsql.yourdomainname/dbname_domain_com";
String username = "dbusername";
String password = "dbpassword";
try {
conn = DriverManager.getConnection(connectionString,
username,
password);
} catch (SQLEException sqle) {
//handle your exception;
}
PHP
<?
$host = "pgsql.yourdomainname";
$dbname = "dbname_domain_com";
$username = "dbusername";
$password = "dbpassword";
$connection = pg_connect("host=$host,dbname=$dbname, user=$username,password=$password");
/*
Check to see if connection was successful
*/
?>
CGI/Perl
use DBI;
my $dbh = DBI->connect('Dbi:Pg:dbname=dbname_domain_com;host=pgsql.yourdomainname',
'dbusername',
'dbpassword'
) || die "Database connection not made: $DBI::errstr";
ASP
connStr = "DSN=aspsql;Database=dbname_domain_com;UID=dbusername;PWD=dbpassword;"
'Create the Connection Object
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.ConnectionTimeout = 30
Conn.CommandTimeout = 30
'Open the Connection object
Conn.Open connStr
NOTE: The values for "dbname_domain_com", "dbusername" and "dbpassword" should be replaced with the actual values corresponding to your PostgreSQL database. |