pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Anil Amarakoon <anil@server.awcoldstream.com>
To: Cyril.Ferrand@sophia.inria.fr
Cc: pgsql-interfaces@postgreSQL.org
Subject: Re: [INTERFACES] a JDBC applet
Date: Thu, 09 Jul 1998 13:36:08 -0500
Message-ID: <35A50D98.2E89FFCC@awcoldstream.com> (raw)
References: <35A4D860.2B8E21D8@iutsoph.unice.fr>

Hi!

Postgres 6.3.2 - Redhat 4.2, 5.0,  5.1, (JDK-from blackdown.org) Windoz  NT
4.0 & 95 (Sun JDK) Mac (Metrowerk-JDK lite)
=====================================================================
Connection conn;
Statement stmt;
Resultset rest;

To get Connection:

public void openDir() {

try {
 Class.forName("postgresql.Driver");
conn=DriverManager.getConnection("jdbc:postgresql://liman.awcl.com:5432/adsys","user
Name","passwd");
}catch(SQLException sqle) {
 System.out.println("connection failed");
 sqle.printStackTrace();
}catch(ClassNotFoundException cnfe) {      //optional
 System.out.println("Class not found");
 cnfe.printStackTrace();
}catch(Exception e) {      //optional
 e.printStackTrace(); }

 }



then query:

public void getCusNum()
{
String query1 = "select cnumber from tcustomer";
      vcusNum = new Vector();
try{
stmt = conn.createStatement();
rest = stmt.executeQuery(query1);

while (rest.next()) {
  vcusNum.addElement(new Integer(rest.getInt(1)));
 }
}catch(SQLException sqle) {
}catch(Exception e) {}

}




close the connection:


public void closeDirectory() {

try{
 if(rest != null){
  rest.close();
  rest = null; }
 if(stmt != null) {
  stmt.close();
  stmt = null; }
 if(conn != null) {
  conn.close();
  conn = null; }
 } catch(SQLException sqle) {
  sqle.printStackTrace(); }
 }


Cyril FERRAND wrote:

> Hello
>
>     I look for an example of a Java applet to communicate with a
> postgresql base via JBDC. Because I have a lot of pb with my own one.
> A example like basic.java example is ok.
>
> thanks...
>
> Cyril




view thread (4+ messages)

Message-ID: <35A50D98.2E89FFCC@awcoldstream.com>
Permalink:  ../35A50D98.2E89FFCC@awcoldstream.com/
Also on:    postgresql.org/message-id/35A50D98.2E89FFCC@awcoldstream.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: anil@server.awcoldstream.com, Cyril.Ferrand@sophia.inria.fr
  Subject: Re: [INTERFACES] a JDBC applet
  In-Reply-To: <35A50D98.2E89FFCC@awcoldstream.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox