Re: [INTERFACES] a JDBC applet - Mailing list pgsql-interfaces

From Anil Amarakoon
Subject Re: [INTERFACES] a JDBC applet
Date
Msg-id 35A50D98.2E89FFCC@awcoldstream.com
Whole thread Raw
In response to a JDBC applet  (Cyril FERRAND <cferran2@iutsoph.unice.fr>)
List pgsql-interfaces
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


pgsql-interfaces by date:

Previous
From: "Len Morgan"
Date:
Subject: ODBC Problem
Next
From: Cyril FERRAND
Date:
Subject: perl crashed