home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.os.vms      DEC's VAX* line of computers & VMS.      264,096 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 262,768 of 264,096   
   =?UTF-8?Q?Arne_Vajh=C3=B8j?= to All   
   VMS x86-64 database server   
   06 Jul 25 15:45:13   
   
   From: arne@vajhoej.dk   
      
   As we all know then the available options are currently very limited.   
      
   But I just found a little trick to get one more.   
      
   :-)   
      
   $ write sys$output f$getsyi("VERSION")   
   V9.2-3   
      
   $ type TestPG.java   
   import java.sql.DriverManager;   
   import java.sql.Connection;   
   import java.sql.Statement;   
   import java.sql.ResultSet;   
      
   public class TestPG {   
        public static void main(String[] args) throws Exception {   
            Connection con =   
   DriverManager.getConnection("jdbc:postgresql://localhost:5435/test",   
   "sa", "hemmeligt");   
            Statement stmt = con.createStatement();   
            ResultSet rs = stmt.executeQuery("SELECT f1,f2 FROM t1");   
            while(rs.next()) {   
                int f1 = rs.getInt(1);   
                String f2 = rs.getString(2);   
                System.out.println(f1 + " " + f2);   
            }   
            rs.close();   
            stmt.close();   
            con.close();   
        }   
   }   
   $ javac TestPG.java   
   $ java -cp .:/javalib/postgresql-42_5_1.jar TestPG   
   1 A   
   2 BB   
   3 CCC   
      
   $ type test.c   
   #include    
   #include    
   #include    
      
   #include    
      
   #include    
      
   int main()   
   {   
        PGconn *con = PQconnectdb("host=localhost port=5435 dbname=test   
   user=sa password=hemmeligt");   
        PGresult *res;   
        res = PQprepare(con, "stmt_selectf1f2fromt1", "SELECT f1,f2 FROM   
   t1", 0, NULL);   
        PQclear(res);   
        res = PQexecPrepared(con, "stmt_selectf1f2fromt1", 0, NULL, NULL,   
   NULL, 0);   
        int nrows = PQntuples(res);   
        for(int i = 0; i < nrows; i++)   
        {   
            int f1 = atoi(PQgetvalue(res, i, 0));   
            char f2[51];   
            strcpy(f2, PQgetvalue(res, i, 1));   
            printf("%d %s\n", f1, f2);   
        }   
        PQclear(res);   
        PQexec(con, "DEALLOCATE stmt_selectf1f2fromt1");   
        PQfinish(con);   
        return 0;   
   }   
   $ cc /include=libpq$root:[include] /name=as_is test   
   $ link test + libpq$root:[lib]libpq/libr +   
   libpq$root:[lib]libgpgtypes/libr + ssl111$lib:ssl111$libssl/libr +   
   ssl111$lib:ssl111$libcrypto/libr   
   $ run test   
   1 A   
   2 BB   
   3 CCC   
      
      
   C:\IDEProjects\EclipsePHP\Test>type TestPDO.php   
   setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);   
   $con->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);   
   $stmt = $con->prepare('SELECT f1,f2 FROM t1');   
   $stmt->execute(array());   
   while($row = $stmt->fetch()) {   
        $f1 = $row['f1'];   
        $f2 = $row['f2'];   
        echo "$f1 $f2\r\n";   
   }   
   ?>   
      
   C:\IDEProjects\EclipsePHP\Test>php TestPDO.php   
   1 A   
   2 BB   
   3 CCC   
      
   I cannot use PHP on VMS yet as I don't have a PHP with pgsql and   
   pdo_pgsql. But given that libpq is ported, then those can probably   
   be build.   
      
   So what is happening here?   
      
   PostgreSQL on VMS x86-64????   
      
   No. Sorry.   
      
   I am using a little trick. H2 can emulate both PostgreSQL   
   SQL dialect and PostgreSQL network protocol.   
      
   $ type server.com   
   $ java -cp /javalib/h2-2_2_220.jar "org.h2.tools.Server" -tcp   
   "-tcpAllowOthers" -pg "-pgAllowOthers" -baseDir .   
   $ exit   
   $ @server   
   TCP server running at tcp://192.168.68.40:9092 (others can connect)   
   PG server running at pg://192.168.68.40:5435 (others can connect)   
      
   :-)   
      
   Arne   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca