[Fwd: What may be the url we need to use to connect the Postgres Database with Java] - Mailing list pgsql-admin

From Jesus Sandoval
Subject [Fwd: What may be the url we need to use to connect the Postgres Database with Java]
Date
Msg-id 3BCBB3DD.1337B3CD@mzt.megared.net.mx
Whole thread Raw
List pgsql-admin
Well let me send yo a little example program how to connect to postgresql from
java:

import java.sql.*;

public class Cias {

// Declara e inicializa variables
 protected int idCia;
 protected String nombre;
        public ResultSet rs;

public Cias() throws ClassNotFoundException, SQLException
{
   idCia = 0;
   nombre = new String();
   Class.forName("org.postgresql.Driver");
   Connection db =
DriverManager.getConnection("jdbc:postgresql://localhost/prueba","jesus","jesus");

   Statement st = db.createStatement();
   rs = st.executeQuery("SELECT * from cias");
}

public int getidCia()
{
   return idCia;
}

public String getnombre()
{
   return nombre;
}

public void leeuno() throws SQLException
{
   rs.next();
   idCia = rs.getInt(1);
   nombre = rs.getString(2);
}

public void leenext() throws SQLException
{
   rs.next();
   idCia = rs.getInt(1);
   nombre = rs.getString(2);
}

}

I hope this help you.

Jesus Sandoval
from Mexico

Moovarkku Mudhalvan escribió:

> Hi friends,
>     Greetings. if we use the oracle as backend with Java programming we use
> the url like
>
>     jdbc.oracle.thin@ipaddress
> like this do we have any url need to be used in Postgres if so let me know.
>
> The Driver i got it from the Package...
>
> Thanks
> Mudhalvan M.M
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org


pgsql-admin by date:

Previous
From: "Moovarkku Mudhalvan"
Date:
Subject: Re: What may be the url we need to use to connect the Postgres Database with Java
Next
From: "Nick Fankhauser"
Date:
Subject: Re: What may be the url we need to use to connect the Postgres Database with Java