X-Original-To: pgsql-interfaces-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 539F59FA425 for ; Wed, 28 Jun 2006 14:40:18 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 00783-06 for ; Wed, 28 Jun 2006 14:40:14 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id 49E8B9FA319 for ; Wed, 28 Jun 2006 14:40:14 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.3 Received: from hotmail.com (bay116-f22.bay116.hotmail.com [64.4.38.32]) by svr4.postgresql.org (Postfix) with ESMTP id E4A6A5AF02F for ; Wed, 28 Jun 2006 17:40:13 +0000 (GMT) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Wed, 28 Jun 2006 10:40:11 -0700 Message-ID: Received: from 64.4.38.200 by by116fd.bay116.hotmail.msn.com with HTTP; Wed, 28 Jun 2006 17:40:09 GMT X-Originating-IP: [213.129.232.56] X-Originating-Email: [seppwimmer@hotmail.com] X-Sender: seppwimmer@hotmail.com In-Reply-To: <44A11AC2.3070104@email.it> From: "Robert Wimmer" To: matteo.traina@email.it, pgsql-interfaces@postgresql.org Subject: Re: jdbc windows Date: Wed, 28 Jun 2006 17:40:09 +0000 Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed X-OriginalArrivalTime: 28 Jun 2006 17:40:11.0598 (UTC) FILETIME=[E7E84EE0:01C69AD9] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/41 X-Sequence-Number: 6182 >From: Matteo Traina >i don't understand about use jdbc driver with windows...how do i do for use >it, sorry but i need a little guide/trial because i find it only for linux. the usage of jdbc does not depend on the underlying OS. here is some example code - that also works in windows package at.wiro.sql; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class Postgres { public static void printException(String query,SQLException e) { System.out.println("query : <" + query + ">"); System.out.println("SQL-error : " + e.getErrorCode()); System.out.println("SQL-state : " + e.getSQLState()); System.out.println("SQL-message : " + e.getMessage()); e.printStackTrace(); System.exit(1); } public static Connection connect(String host,String db, String user, String pwd) { String pg_driver = "org.postgresql.Driver"; Connection conn = null; try { Class.forName(pg_driver); } catch (Exception e) { System.out.println("can't load postgres driver '" + pg_driver + "' ..."); System.exit(1); } try { conn = DriverManager.getConnection("jdbc:postgresql://" + host + "/" + db,user,pwd); } catch (SQLException e) { System.out.println("can't connect to db '"+db+"' as user '" + user + "' ..."); printException("Connection Error : ",e); System.out.println("system halted ..."); System.exit(1); } return conn; } public static ResultSet query(Connection conn,String query) { ResultSet rs = null; try { Statement st = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE); rs = st.executeQuery(query); } catch (SQLException e) { printException(query,e);} return rs; } .... regards sepp