Re: [INTERFACES] a JDBC applet

Поиск
Список
Период
Сортировка
От Anil Amarakoon
Тема Re: [INTERFACES] a JDBC applet
Дата
Msg-id 35A50D98.2E89FFCC@awcoldstream.com
обсуждение исходный текст
Ответ на a JDBC applet  (Cyril FERRAND <cferran2@iutsoph.unice.fr>)
Список 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 по дате отправления:

Предыдущее
От: "Len Morgan"
Дата:
Сообщение: ODBC Problem
Следующее
От: Cyril FERRAND
Дата:
Сообщение: perl crashed