From: | "Heikki Linnakangas" <heikki(at)enterprisedb(dot)com> |
---|---|
To: | "Andreas" <maps(dot)on(at)gmx(dot)net> |
Cc: | <pgsql-jdbc(at)postgresql(dot)org> |
Subject: | Re: Hello World |
Date: | 2006-11-21 09:45:53 |
Message-ID: | 4562CAD1.5090603@enterprisedb.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
Attachment | Content-Type | Size |
---|---|---|
JdbcTest.java | text/x-java | 396 bytes |
From | Date | Subject | |
---|---|---|---|
Next Message | Heikki Linnakangas | 2006-11-21 10:30:13 | Re: exception with a temporary table |
Previous Message | Ido M. Tamir | 2006-11-21 09:35:40 | Re: Hello World |