Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 21B724758C9 for ; Sun, 19 Jan 2003 14:09:41 -0500 (EST) Received: from ev6.be.wanadoo.com (ev6.be.wanadoo.com [195.74.212.41]) by postgresql.org (Postfix) with ESMTP id 374EC47580B for ; Sun, 19 Jan 2003 14:09:38 -0500 (EST) Received: from principalb (adsl-80-236-152-100.wanadoo.be [80.236.152.100]) by ev6.be.wanadoo.com (8.11.1/8.11.1) with SMTP id h0JJ9Yq09996 for ; Sun, 19 Jan 2003 20:09:35 +0100 Message-ID: <000801c2bfed$76d489f0$010210ac@principalb> From: "michel verplancke" To: Subject: jdbc connection Date: Sun, 19 Jan 2003 20:03:31 +0100 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0005_01C2BFF5.D71F7150" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-DCC-wanadoo-be-Metrics: ev6 1023; Body=2 Fuz1=2 Fuz2=2 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/255 X-Sequence-Number: 6105 This is a multi-part message in MIME format. ------=_NextPart_000_0005_01C2BFF5.D71F7150 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Please can you help me I try to connect a java application from a windows W2K to a Linux postgresq= l with a very simple query, which is "select * from table". The error message is "connection is closed, operation is not permitted" here is the class definition import java.sql.*; =20 public class JdbcQuery { private Connection con =3D null; public int recordnb =3D 0; private Statement stmt =3D null; private ResultSet result =3D null; private String driver =3D "org.postgresql.Driver"; private String url =3D "jdbc:postgresql://COMPUTERNAME:5432/DATABASE"; private String username =3D "michels"; private String password =3D ""; boolean ConnectPostgresql(String Valquery) {=20 try // Attempt to load the JDBC driver {=20=20=20=20=20 Class.forName(driver); }=20 catch( Exception e ) // error { JOptionPane.showMessageDialog(null, "Failed to load the following JDBC dr= iver : " + e.getMessage(), "Error ! ", JOptionPane.PLAIN_MESSAGE); return false; }=20 try { con =3D DriverManager.getConnection ( url, username, password); stmt =3D con.createStatement(); } catch ( Exception e) { JOptionPane.showMessageDialog(null, "Problems connecting to " + url + ":= " + e.getMessage(), "Error ! ", JOptionPane.PLAIN_MESSAGE); return false; } if( con !=3D null) { try { con.close(); } catch( Exception e2 ) {} }=20 try { result =3D stmt.executeQuery(Valquery); IT's HERE THAT I GET TH= E PROBLEM !!!!!!! }=20 catch (Exception e)=20=20 { JOptionPane.showMessageDialog(null, "Problems with resultset : " + e.get= Message(), "Error ! ", JOptionPane.PLAIN_MESSAGE); return false; } return true; } int GetRecordnb()=20 { try { result.last(); recordnb =3D result.getRow(); result.beforeFirst(); } // end try catch ( Exception e) { System.err.println( "problems in GetRecordnb managing resultset" ); System.err.println( e.getMessage() ); if( con !=3D null) { try { con.close(); } catch( Exception e2 ) {} }=20 } // end catch=20 return recordnb; } // alternative (donne le m=EAme r=E9sultat que la mani=E8re pr=E9c=E9dente) // System.out.println(result.getFetchSize());=20 ResultSet GetRecordData()=20 { return result; } void CloseConnection() { try { stmt.close(); } catch( Exception e ) {} try { con.close(); } catch( Exception e ) {} }=20 } // end class=20 If I try the same query from the Cygwin psql it works !! Does somebody have an idea ? Thanks michel.verplancke@wanadoo.be =20=20 ------=_NextPart_000_0005_01C2BFF5.D71F7150 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Please can you help me
 
I try to connect a java application from a= windows=20 W2K to a Linux postgresql with a very simple query, which is "select *= from=20 table".
 
The error message is "connection is c= losed,=20 operation is not permitted"
 
here is the class definition
 
 import java.sql.*;
 
public class JdbcQuery {
 &nbs= p; =20 private Connection con =3D null;
    public int recordnb = =3D=20 0;
    private Statement stmt =3D null;
  &n= bsp;=20 private ResultSet result =3D null;
 
    private String driv= er =3D=20 "org.postgresql.Driver";
    private String url =3D=20 "jdbc:postgresql://COMPUTERNAME:5432/DATABASE";
    priva= te=20 String username =3D "michels";
    private String passwor= d =3D=20 "";
 
boolean ConnectPostgresql(String Valqu= ery)=20 { 
 try   // Attempt to load the JDBC=20 driver
   =20  {     
     Clas= s.forName(driver);
  =20   } 
    catch( Exception e )  //=20 error
   =20  {
  JOptionPane.showMessageDialog(null, "Failed to load = the=20 following JDBC driver : " + e.getMessage(), "Error ! ",=20 JOptionPane.PLAIN_MESSAGE);
  return=20 false;
      }
   =20 try
     {
  con =3D=20 DriverManager.getConnection ( url, username, password);
  stmt= =3D=20 con.createStatement();
     }
    = catch=20 ( Exception e)
   =20  {
   JOptionPane.showMessageDialog(null, "Problems= =20 connecting to " + url + ":" + e.getMessage(), "Error ! ",=20 JOptionPane.PLAIN_MESSAGE);
  return=20 false;
   }
      if( con != =3D=20 null)
     =20  {
         try { con.close= ();=20 }
         catch( Exception e2 )= =20 {}
      }
  =20  try
     {
  result =3D=20 stmt.executeQuery(Valquery);        = ;   IT's HERE THAT I GET THE PROBLEM=20 !!!!!!!
     }
   = ;=20 catch (Exception e) =20
  {
   JOptionPane.showMessageDialog(null,= =20 "Problems with resultset : " + e.getMessage(), "Error ! ",=20 JOptionPane.PLAIN_MESSAGE);
  return=20 false;
  }
 return true;
  }
<= /DIV>
 
int GetRecordnb()=20
 {
     try
   =20  {
  result.last();
  recordnb =3D=20 result.getRow();
  result.beforeFirst();
 
     } // end=20 try
    catch ( Exception e)
   =20  {
        System.err.println(= =20 "problems in GetRecordnb managing resultset"=20 );
        System.err.println(=20 e.getMessage() );
      if( con !=3D=20 null)
     =20  {
         try { con.close= ();=20 }
         catch( Exception e2 )= =20 {}
      }
     } // en= d=20 catch 
  return recordnb;
 }
 
// alternative (donne le m=EAme r=E9su= ltat que la=20 mani=E8re pr=E9c=E9dente)
 
// System.out.println(result.getFetchSize()); <= /FONT>
 
ResultSet GetRecordData()=20
 {
 return result;
 }
 
void=20 CloseConnection()
 {
  try { stmt.close();=20 }
        catch( Exception e )=20 {}
        try { con.close();=20 }
        catch( Exception e )=20 {}
       }
 
} // end class
 
If I try the same query from the Cygwin ps= ql it=20 works !!
 
Does somebody have an idea ?
 
Thanks
 
michel.verplancke@wanadoo.be
  
 
------=_NextPart_000_0005_01C2BFF5.D71F7150--