From shavonne.marietta@studioform.it Thu Mar 27 14:48:01 2008 Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id E15AA2E005F for ; Thu, 27 Mar 2008 11:48:01 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 38960-02 for ; Thu, 27 Mar 2008 11:47:56 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from smtpout26.attiva.biz (smtpout26.attiva.biz [85.37.16.27]) by postgresql.org (Postfix) with ESMTP id 640A82E005E for ; Thu, 27 Mar 2008 11:47:54 -0300 (ADT) Received: from FBCMFE02B15.fbc.local ([192.168.30.161]) by smtpout26.attiva.biz with Microsoft SMTPSVC(6.0.3790.1830); Thu, 27 Mar 2008 15:47:50 +0100 Received: from DREAM ([88.34.161.130]) by FBCMFE02B15.fbc.local with Microsoft SMTPSVC(6.0.3790.1830); Thu, 27 Mar 2008 15:47:49 +0100 Message-ID: <013001c89019$88e91d20$0602a8c0@DREAM> Reply-To: "Shavonne Marietta Wijesinghe" From: "Shavonne Marietta Wijesinghe" To: Subject: link to Jsp Date: Thu, 27 Mar 2008 15:47:51 +0100 Organization: Studio FORM MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_012D_01C89021.EA38A340" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.3138 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198 X-OriginalArrivalTime: 27 Mar 2008 14:47:49.0945 (UTC) FILETIME=[8759CA90:01C89019] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200803/199 X-Sequence-Number: 30527 This is a multi-part message in MIME format. ------=_NextPart_000_012D_01C89021.EA38A340 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hello I'm trying to connect to my postgresql db from a JSP page but my db is = on one computer and the jsp in another..=20 Has anyone done something like this before?? private synchronized Connection getConnection() throws = ClassNotFoundException, SQLException { final String DRIVER =3D "org.postgresql.Driver"; final String URL =3D "jdbc:postgresql:FormAjax"; final String USERNAME =3D "postgres"; final String PASSWORD =3D "form"; =20 Class.forName(DRIVER); =20 return DriverManager.getConnection(URL, USERNAME, PASSWORD); } Thanks Shavonne Wijesinghe ------=_NextPart_000_012D_01C89021.EA38A340 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hello
 
I'm trying to connect to my postgresql = db from a=20 JSP page but my db is on one computer and the jsp in another.. =
 
Has anyone done something like this=20 before??
 
 private synchronized Connection=20 getConnection() throws = ClassNotFoundException,
     =20 SQLException {
    final String DRIVER =3D=20 "org.postgresql.Driver";
    final String URL =3D=20 "jdbc:postgresql:FormAjax";
    final String USERNAME = =3D=20 "postgres";
    final String PASSWORD =3D = "form";
 =20
    Class.forName(DRIVER);
  =
   =20 return DriverManager.getConnection(URL, USERNAME,=20 PASSWORD);
 }
 
Thanks
 
Shavonne = Wijesinghe
------=_NextPart_000_012D_01C89021.EA38A340-- From craig@postnewspapers.com.au Thu Mar 27 18:02:42 2008 Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id A44CA2E008C for ; Thu, 27 Mar 2008 15:02:42 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 85336-03-2 for ; Thu, 27 Mar 2008 15:02:34 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from www.postnewspapers.com.au (www.postnewspapers.com.au [202.61.230.242]) by postgresql.org (Postfix) with ESMTP id 1CE2A2E0097 for ; Thu, 27 Mar 2008 15:02:36 -0300 (ADT) Received: from mail.postnewspapers.com.au (202-89-185-120.static.dsl.amnet.net.au [202.89.185.120]) by www.postnewspapers.com.au (Postfix) with ESMTP id 315E7D559A; Fri, 28 Mar 2008 03:02:30 +0900 (WST) Received: from [10.0.0.53] (wallace.localnet [10.0.0.53]) by mail.postnewspapers.com.au (Postfix) with ESMTP id 99DE01E0434; Fri, 28 Mar 2008 03:02:31 +0900 (WST) Message-ID: <47EBE137.8060009@postnewspapers.com.au> Date: Fri, 28 Mar 2008 03:02:31 +0900 From: Craig Ringer User-Agent: Icedove 1.5.0.12 (X11/20070607) MIME-Version: 1.0 To: Shavonne Marietta Wijesinghe Cc: pgsql-sql@postgresql.org Subject: Re: link to Jsp References: <013001c89019$88e91d20$0602a8c0@DREAM> In-Reply-To: <013001c89019$88e91d20$0602a8c0@DREAM> X-Enigmail-Version: 0.94.2.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200803/201 X-Sequence-Number: 30529 Shavonne Marietta Wijesinghe wrote: > Hello > > I'm trying to connect to my postgresql db from a JSP page but my db is on one computer and the jsp in another.. > > Has anyone done something like this before?? > > private synchronized Connection getConnection() throws ClassNotFoundException, > SQLException { > final String DRIVER = "org.postgresql.Driver"; > final String URL = "jdbc:postgresql:FormAjax"; Read the documentation for the PostgreSQL JDBC layer, particularly the part about the JDBC URL. I quote: ------------ The JDBC URL In JDBC all url's begin with jdbc:protocol: This is the standard. After this is driver specific, and no two drivers are the same. So our url? It's one of the following: jdbc:postgresql:database jdbc:postgresql://host/database jdbc:postgresql://host:port/database where database is the database to connect to, host the server to connect to, and port the port number. If left out, host defaults to localhost (not 127.0.0.1 see applets!) and port to 5432 (configurable at build time). ----------- -- Craig Ringer