Skip to content

Commit

Permalink
Enable support for multiple DBDI drivers.
Browse files Browse the repository at this point in the history
  • Loading branch information
timbunce committed Jul 27, 2010
1 parent 28e0ca2 commit e0c7a61
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions DBDI_pg.pm6
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -110,14 +110,17 @@ class DBDI_pg::Driver does java::sql::Driver {


DBDI::DriverManager.registerDriver( DBDI_pg::Driver.new ); DBDI::DriverManager.registerDriver( DBDI_pg::Driver.new );



multi method connect ( multi method connect (
Str $url, Str $url is copy,
Hash $prop, Hash $prop,
--> java::sql::Connection --> java::sql::Connection
) { ) {
say "> connect '$url'"; say "> connect '$url'";

return fail() if not $url ~~ s/^dbdi\:postgres\://;

my $conninfo = "host=localhost $url user=$prop.<user> password=$prop.<password>"; my $conninfo = "host=localhost $url user=$prop.<user> password=$prop.<password>";
say "- connect '$conninfo'";
my $db_conn = PQconnectdb($conninfo); my $db_conn = PQconnectdb($conninfo);
if (PQstatus($db_conn) != CONNECTION_OK) { if (PQstatus($db_conn) != CONNECTION_OK) {
my $msg = PQerrorMessage($db_conn); my $msg = PQerrorMessage($db_conn);
Expand Down
2 changes: 1 addition & 1 deletion dbdi.pl6
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use DBDI_pg;


my $dbname = @*ARGS.shift || prompt 'Database: '; my $dbname = @*ARGS.shift || prompt 'Database: ';


my $con = DBDI::DriverManager.getConnection("dbname=$dbname", 'testuser', 'testpass'); my $con = DBDI::DriverManager.getConnection("dbdi:postgres:dbname=$dbname", 'testuser', 'testpass');


while prompt 'SQL: ' -> $sql { while prompt 'SQL: ' -> $sql {


Expand Down

0 comments on commit e0c7a61

Please sign in to comment.