pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Hello World
6+ messages / 6 participants
[nested] [flat]

* Hello World
@ 2006-11-21 06:00  Andreas <maps.on@gmx.net>
  0 siblings, 3 replies; 6+ messages in thread

From: Andreas @ 2006-11-21 06:00 UTC (permalink / raw)
  To: pgsql-jdbc

Hi,

first of all I'll have to confess I don't know next to nothing at all 
about JAVA, yet.
On the other hand I'm not exactly new to programming nor PostgreSQL either.

Is there a "Hello World" level sample for jdbc with PG?

Lets suppose I allready have a running PG with a db db_test that has a 
few tables among which there is tbl_test in schema s.
The db-server might be 192.168.0.100.
User could be "user1" with password "pw1".

What would be minimally needed to connect to db_test and read the 
content of tbl_test to the console and logg off from PG.

I'd prefer a complete sample code that could be dumped through javac.




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Hello World
@ 2006-11-21 09:35  Ido M. Tamir <tamir@imp.univie.ac.at>
  parent: Andreas <maps.on@gmx.net>
  2 siblings, 0 replies; 6+ messages in thread

From: Ido M. Tamir @ 2006-11-21 09:35 UTC (permalink / raw)
  To: pgsql-jdbc

Andreas wrote:

> Hi,
> 
> first of all I'll have to confess I don't know next to nothing at all
> about JAVA, yet.
> On the other hand I'm not exactly new to programming nor PostgreSQL
> either.

http://java.sun.com/docs/books/tutorial/jdbc/index.html

Just follow this tutorial step by step.

HTH
ido




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Hello World
@ 2006-11-21 09:45  Heikki Linnakangas <heikki@enterprisedb.com>
  parent: Andreas <maps.on@gmx.net>
  2 siblings, 0 replies; 6+ messages in thread

From: Heikki Linnakangas @ 2006-11-21 09:45 UTC (permalink / raw)
  To: Andreas <maps.on@gmx.net>; +Cc: pgsql-jdbc

Andreas wrote:
> Hi,
> 
> first of all I'll have to confess I don't know next to nothing at all 
> about JAVA, yet.
> On the other hand I'm not exactly new to programming nor PostgreSQL either.
> 
> Is there a "Hello World" level sample for jdbc with PG?

I'd suggest to read the Java Tutorial by Sun:

http://java.sun.com/docs/books/tutorial/

and after you got the basics, move on to the JDBC trail of the tutorial:

http://java.sun.com/docs/books/tutorial/jdbc/index.html

> Lets suppose I allready have a running PG with a db db_test that has a 
> few tables among which there is tbl_test in schema s.
> The db-server might be 192.168.0.100.
> User could be "user1" with password "pw1".
> 
> What would be minimally needed to connect to db_test and read the 
> content of tbl_test to the console and logg off from PG.
> 
> I'd prefer a complete sample code that could be dumped through javac.

A sample attached. Save it to a file called JdbcTest.java, modify the 
server address, database name, table name etc. to suite your needs, and 
compile with "javac JdbcTest.java". To run, add postgresql.jar to your 
classpath. For example:

java -cp path/to/postgresql.jar JdbcTest

-- 
   Heikki Linnakangas
   EnterpriseDB   http://www.enterprisedb.com

Attachments:

JdbcTest.java (text/x-java, 395B) download import java.sql.*; public class JdbcTest { public static void main(String[] args) throws Exception { Class.forName("org.postgresql.Driver"); Connection conn = DriverManager.getConnection("jdbc:postgresql://localhost/testdb", "username", "pw"); ResultSet rs = conn.prepareStatement("SELECT * FROM test").executeQuery(); while(rs.next()) System.out.println(rs.getString(1)); } }
^ permalink raw reply [nested|flat] 6+ messages in thread

* Re: Hello World
@ 2006-11-21 12:50  Albert Cardona <acardona@ini.phys.ethz.ch>
  0 siblings, 0 replies; 6+ messages in thread

From: Albert Cardona @ 2006-11-21 12:50 UTC (permalink / raw)
  To: pgsql-jdbc


Have a look at this file:

http://www.pensament.net/java/other_plugins.html#postgresql
http://www.pensament.net/java/PostgreSQL_.java

It shows how to connect and insert/query an image as bytea. Works on top of
ImageJ http://rsb.info.nih.gov/ij/ , a public domain minimalistic java image
processing application.

Albert
--
Albert Cardona
Molecular Cell Developmental Biology
University of California Los Angeles
Tel +1 310 2067376
Programming: http://www.ini.unizh.ch/~acardona/trakem2.html
Research: http://www.mcdb.ucla.edu/Research/Hartenstein/
Web design: http://www.pixelets.com




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Hello World
@ 2006-11-21 17:52  Michael Schmidt <michaelmschmidt@msn.com>
  parent: Andreas <maps.on@gmx.net>
  2 siblings, 1 reply; 6+ messages in thread

From: Michael Schmidt @ 2006-11-21 17:52 UTC (permalink / raw)
  To: pgsql-jdbc; Andreas <maps.on@gmx.net>

Andreas,
I was in a similar situation about two years ago and have, slowly, learned a bit about Java.  Java itself is deceptively simple but to use it effectively, you will want to use one of the IDE platforms.  I chose Eclipse over the others because it allows native access to SWT and JFace, and because it is open-source and free (like PostgreSQL).  Eclipse has a pretty steep learning curve, but being a stubborn German, I stuck with it and now am able to do most things fairly easily.  For the beginner, I would recommend investing in the Designer or RCP builder plug-in from Instantiations.

Working on my application, I realized that I could start by writing a basic, generic UI and then add custom features specific to my application later.  I made the generic UI available at PgFoundry (the Komo project).  It includes database access (password and other settings), as well as general utilities (back up, restore, vacuum).  The code isn't perfect, but it works.  Hopefully, this will serve as the "Hello World" application you are looking for.  Here's the link http://pgfoundry.org/projects/komo-client/<http://pgfoundry.org/projects/komo-client/; 

Michael Schmidt

  ----- Original Message ----- 
  From: Andreas<mailto:maps.on@gmx.net> 
  To: pgsql-jdbc@postgresql.org<mailto:pgsql-jdbc@postgresql.org> 
  Sent: Monday, November 20, 2006 11:00 PM
  Subject: [JDBC] Hello World


  Hi,

  first of all I'll have to confess I don't know next to nothing at all 
  about JAVA, yet.
  On the other hand I'm not exactly new to programming nor PostgreSQL either.

  Is there a "Hello World" level sample for jdbc with PG?

  Lets suppose I allready have a running PG with a db db_test that has a 
  few tables among which there is tbl_test in schema s.
  The db-server might be 192.168.0.100.
  User could be "user1" with password "pw1".

  What would be minimally needed to connect to db_test and read the 
  content of tbl_test to the console and logg off from PG.

  I'd prefer a complete sample code that could be dumped through javac.


  ---------------------------(end of broadcast)---------------------------
  TIP 3: Have you checked our extensive FAQ?

                 http://www.postgresql.org/docs/faq<http://www.postgresql.org/docs/faq;

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Hello World
@ 2006-11-21 20:12  imad <immaad@gmail.com>
  parent: Michael Schmidt <michaelmschmidt@msn.com>
  0 siblings, 0 replies; 6+ messages in thread

From: imad @ 2006-11-21 20:12 UTC (permalink / raw)
  To: Michael Schmidt <michaelmschmidt@msn.com>; +Cc: pgsql-jdbc; Andreas <maps.on@gmx.net>

Could not find anything more "Hello World" than this :-)

http://www.fankhausers.com/postgresql/jdbc/


--Imad
www.EnterpriseDB.com


On 11/21/06, Michael Schmidt <michaelmschmidt@msn.com> wrote:
>
>
>
> Andreas,
> I was in a similar situation about two years ago and have, slowly, learned a
> bit about Java.  Java itself is deceptively simple but to use it
> effectively, you will want to use one of the IDE platforms.  I chose Eclipse
> over the others because it allows native access to SWT and JFace, and
> because it is open-source and free (like PostgreSQL).  Eclipse has a pretty
> steep learning curve, but being a stubborn German, I stuck with it and now
> am able to do most things fairly easily.  For the beginner, I would
> recommend investing in the Designer or RCP builder plug-in from
> Instantiations.
>
> Working on my application, I realized that I could start by writing a basic,
> generic UI and then add custom features specific to my application later.  I
> made the generic UI available at PgFoundry (the Komo project).  It includes
> database access (password and other settings), as well as general utilities
> (back up, restore, vacuum).  The code isn't perfect, but it works.
> Hopefully, this will serve as the "Hello World" application you are looking
> for.  Here's the link
> http://pgfoundry.org/projects/komo-client/
>
> Michael Schmidt
>
>
> ----- Original Message -----
> From: Andreas
> To: pgsql-jdbc@postgresql.org
> Sent: Monday, November 20, 2006 11:00 PM
> Subject: [JDBC] Hello World
>
> Hi,
>
> first of all I'll have to confess I don't know next to nothing at all
> about JAVA, yet.
> On the other hand I'm not exactly new to programming nor PostgreSQL either.
>
> Is there a "Hello World" level sample for jdbc with PG?
>
> Lets suppose I allready have a running PG with a db db_test that has a
> few tables among which there is tbl_test in schema s.
> The db-server might be 192.168.0.100.
> User could be "user1" with password "pw1".
>
> What would be minimally needed to connect to db_test and read the
> content of tbl_test to the console and logg off from PG.
>
> I'd prefer a complete sample code that could be dumped through javac.
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
>                http://www.postgresql.org/docs/faq
>



^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2006-11-21 20:12 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-11-21 06:00 Hello World Andreas <maps.on@gmx.net>
2006-11-21 09:35 ` Ido M. Tamir <tamir@imp.univie.ac.at>
2006-11-21 09:45 ` Heikki Linnakangas <heikki@enterprisedb.com>
2006-11-21 17:52 ` Michael Schmidt <michaelmschmidt@msn.com>
2006-11-21 20:12   ` imad <immaad@gmail.com>
2006-11-21 12:50 Re: Hello World Albert Cardona <acardona@ini.phys.ethz.ch>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox