Permalink
Browse files

delete DBDI related files that have moved to a new dbdi repro

  • Loading branch information...
1 parent a217760 commit fc7891114dd7f7fc8adadb381f6407bdf2cd65bd @timbunce committed Jul 27, 2010
Showing with 0 additions and 354 deletions.
  1. +0 −40 DBDI.pm6
  2. +0 −135 DBDI_pg.pm6
  3. +0 −7 dbdi-init.sh
  4. +0 −23 dbdi.pl6
  5. +0 −20 jdbclib-typemap
  6. +0 −39 jdbclib-update.pl
  7. +0 −3 libpq-test.pl6
  8. +0 −87 libpq.pm6
View
@@ -1,40 +0,0 @@
-use v6;
-
-class java::sql::Driver { ... };
-class java::sql::Connection { ... };
-
-use java::sql::DriverManager;
-
-class DBDI::DriverManager does java::sql::DriverManager {
-
- my %drivers;
-
- method registerDriver ( java::sql::Driver $driver ) {
- say "registerDriver($driver)";
- %drivers{$driver} = $driver;
- } # throws java.sql.SQLException
-
- multi method getConnection (
- Str $url,
- Str $user,
- Str $pass,
- --> java::sql::Connection
- ) {
- say "> getConnection($url, $user, $pass)";
-
- my Hash $opt .= new;
- $opt.<user> = $user;
- $opt.<password> = $pass;
-
- my $con;
- for %drivers.values -> $driver {
- $con = $driver.connect($url, $opt);
- last if $con;
- }
- die "Unable to find a driver to handle $url" if not $con;
-
- say "< getConnection $con";
- return $con;
- }
-
-}
View
@@ -1,135 +0,0 @@
-use v6;
-
-use java::sql::Driver;
-use java::sql::Connection;
-use java::sql::Statement;
-use java::sql::ResultSet;
-use java::sql::ResultSetMetaData;
-
-use libpq;
-
-class DBDI_pg::ResultSetMetaData does java::sql::ResultSetMetaData {
- has $conn;
- has $db_conn;
- has $db_res;
-
-
- method getColumnCount (
- --> Int # int
- ) {
- return PQnfields($db_res);
- } # throws java.sql.SQLException
-
-
- method getColumnLabel (
- Int $v1, # int
- --> Str # java.lang.String
- ) {
- return PQfname($db_res, $v1-1);
- } # throws java.sql.SQLException
-
-}
-
-
-class DBDI_pg::ResultSet does java::sql::ResultSet {
- has $conn;
- has $db_conn;
- has $db_res;
- has $row_num;
- has $metadata;
-
-
- method next (
- --> Bool # boolean
- ) {
- return (++$row_num <= PQntuples($db_res));
- } # throws java.sql.SQLException
-
-
- multi method getString (
- Int $v1, # int
- --> Str
- ) {
- return Mu if PQgetisnull($db_res, $row_num-1, $v1-1);
- my $field = PQgetvalue($db_res, $row_num-1, $v1-1);
- return $field;
- } # throws java.sql.SQLException
-
-
- method getMetaData (
- --> java::sql::ResultSetMetaData
- ) {
- return $metadata ||= DBDI_pg::ResultSetMetaData.new(:conn(self), :$db_conn, :$db_res);
- } # throws java.sql.SQLException
-
-
-}
-
-class DBDI_pg::Statement does java::sql::Statement {
-
- has $conn;
- has $db_conn;
-
- method executeQuery (
- Str $v1,
- --> java::sql::ResultSet
- ) {
- say "> executeQuery $v1";
-
- my $db_res = PQexec($db_conn, $v1);
- if (PQresultStatus($db_res) != PGRES_TUPLES_OK)
- {
- my $msg = PQerrorMessage($db_conn);
- PQclear($db_res);
- die sprintf("FETCH ALL failed: %s", $msg);
- }
-
- my $result = DBDI_pg::ResultSet.new(:conn(self), :$db_conn, :$db_res);
- say "< executeQuery";
- return $result;
- }
-
-}
-
-class DBDI_pg::Connection does java::sql::Connection {
-
- has $db_conn;
-
- multi method createStatement (
- --> java::sql::Statement
- ) {
- say "> createStatement";
- my $stmt = DBDI_pg::Statement.new(:conn(self), :$db_conn);
- say "< createStatement";
- return $stmt;
- }
-
-}
-
-class DBDI_pg::Driver does java::sql::Driver {
-
- DBDI::DriverManager.registerDriver( DBDI_pg::Driver.new );
-
- multi method connect (
- Str $url is copy,
- Hash $prop,
- --> java::sql::Connection
- ) {
- say "> connect '$url'";
-
- return fail() if not $url ~~ s/^dbdi\:postgres\://;
-
- my $conninfo = "host=localhost $url user=$prop.<user> password=$prop.<password>";
- say "- connect '$conninfo'";
- my $db_conn = PQconnectdb($conninfo);
- if (PQstatus($db_conn) != CONNECTION_OK) {
- my $msg = PQerrorMessage($db_conn);
- die sprintf( "Connection to database ($conninfo) failed: %s %s", $msg, PQstatus($db_conn));
- }
- my DBDI_pg::Connection $conn .= new( :$db_conn );
-
- say "< connect";
- return $conn;
- }
-
-}
View
@@ -1,7 +0,0 @@
-# source into your shell
-export PERL6LIB=".:jdbclib:$PERL6LIB"
-
-# Also need to ensure the native postgres libpq is loadable
-# For OS X you'll need something like this in your ~/.profile
-# export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/usr/local/pgsql/lib/
-
View
@@ -1,23 +0,0 @@
-use v6;
-
-use DBDI;
-use DBDI_pg;
-
-# e.g. "dbdi:postgres:dbname=$dbname"
-my $url = @*ARGS.shift || prompt "Enter a 'dbdi:driver:...' URL: ";
-
-my $con = DBDI::DriverManager.getConnection($url, 'testuser', 'testpass');
-
-while prompt 'SQL: ' -> $sql {
-
- my $result = $con.createStatement.executeQuery($sql);
- my $meta = $result.getMetaData;
-
- my @names = map { $meta.getColumnLabel($_) }, 1..$meta.getColumnCount;
- say @names.join(", ");
-
- while ( $result.next ) {
- my @row = map { $result.getString($_) }, 1..@names.elems;
- say @row.join(", ");
- }
-}
View
@@ -1,20 +0,0 @@
-java.io.PrintStream IO
-java.io.PrintWriter IO
-java.lang.Throwable Any
-java.net.URL Str
-java.net.URLConnection Any
-java.net.URLStreamHandler Any
-java.net.URLStreamHandlerFactory Any
-java.security.BasicPermission Any
-java.sql.Blob Buf
-java.sql.Clob Str
-java.sql.NClob Str
-java.sql.SQLPermission Any
-java.sql.SQLXML Str
-javax.sql.ConnectionEvent Any
-javax.sql.ConnectionEventListener Any
-javax.sql.RowSetListener Any
-javax.sql.StatementEventListener Any
-javax.sql.XAConnection Any
-
-
View
@@ -1,39 +0,0 @@
-#!/usr/bin/env perl
-
-=head1 NAME
-
-mkjdbc.pl - generate the perl6 translation of the classes related to JDBC
-
-=head1 SYNOPSIS
-
- perl mkjdbc.pl
-
-=head1 DESCRIPTION
-
-This is just a quick hack to exercise java2perl6api with the use case that
-interests us most: JDBC.
-
-The jdbc_classes.txt class file lists the Java classes related to JDBC.
-This script translates those classes into the corresponding perl6 classes and
-roles in the jdbclib directory.
-
-If a jdbclib directory already exists it's renamed to jdbclib.prev and, at the
-end of the run, the contents of the directory are compared.
-
-=cut
-
-use strict;
-use warnings;
-use autodie qw(:all);
-use Cwd qw(getcwd);
-
-my $outdir = 'jdbclib';
-
-system qq{rm -rf $outdir.prev} if -d "$outdir.prev";
-system qq{mv -f $outdir $outdir.prev} if -d $outdir;
-
-system qq{time perl -Mlib=lib bin/java2perl6api --add_types jdbclib-typemap --outdir $outdir @ARGV java.sql.DriverManager};
-
-system qq{diff -wr --exclude=*.pir -u $outdir.prev $outdir} || warn "Output differs\n"
- if -d "$outdir.prev";
-
View
@@ -1,3 +0,0 @@
-use v6;
-use libpq;
-say CONNECTION_OK();
View
@@ -1,87 +0,0 @@
-module libpq;
-
-use NativeCall; # from project 'zavolaj'
-
-# -------- foreign function definitions in alphabetical order ----------
-
-# hacked from http://github.com/jnthn/zavolaj/blob/master/examples/postgresqlclient.p6
-# See http://www.postgresql.org/docs/9.0/static/libpq-example.html
-
-
-sub PQclear( OpaquePointer $res )
- is export
- is native('libpq')
- { ... }
-
-sub PQconnectdb( Str $conninfo )
- returns OpaquePointer
- is export
- is native('libpq')
- { ... }
-
-sub PQerrorMessage( OpaquePointer $conn )
- returns Str
- is export
- is native('libpq')
- { ... }
-
-sub PQexec( OpaquePointer $conn, Str $command )
- returns OpaquePointer
- is export
- is native('libpq')
- { ... }
-
-sub PQfinish( OpaquePointer $conn )
- is export
- is native('libpq')
- { ... }
-
-sub PQfname( OpaquePointer $res, Int $fieldnum )
- returns Str
- is export
- is native('libpq')
- { ... }
-
-sub PQgetisnull( OpaquePointer $res, Int $tuplenum, Int $fieldnum )
- returns Int
- is export
- is native('libpq')
- { ... }
-
-sub PQgetvalue( OpaquePointer $res, Int $tuplenum, Int $fieldnum )
- returns Str
- is export
- is native('libpq')
- { ... }
-
-sub PQnfields( OpaquePointer $res )
- returns Int
- is export
- is native('libpq')
- { ... }
-
-sub PQntuples( OpaquePointer $res )
- returns Int
- is export
- is native('libpq')
- { ... }
-
-sub PQresultStatus( OpaquePointer $res )
- returns Int
- is export
- is native('libpq')
- { ... }
-
-sub PQstatus( OpaquePointer $conn )
- returns Int
- is export
- is native('libpq')
- { ... }
-
- # from libpq-fe.h These should of course be constants or perhaps even enums
-sub CONNECTION_OK is export { 0 }
-sub CONNECTION_BAD is export { 1 }
-
-sub PGRES_EMPTY_QUERY is export { 0 }
-sub PGRES_COMMAND_OK is export { 1 }
-sub PGRES_TUPLES_OK is export { 2 }

0 comments on commit fc78911

Please sign in to comment.