How to connect to PostgreSQL with JDBC driver

Facebooktwittergoogle_plustumblrFacebooktwittergoogle_plustumblr
Postgres JDBC Java
Postgres JDBC Java

This is an example to show how to connect to PostgreSQL database via a JDBC driver.

First, download PostgreSQL JDBC driver.

To run this code, your need postgresql-{version}-bin.jar in your classpath.

JDBCPostgreSQLExample.java

To run this code you should put JDBCPostgreSQLExample.java in one folder along with the PostgreSQL JDBC driver, for example c:\test, and execute:

C:\test>java -cp c:\test\postgresql-8.3-603.jdbc4.jar;c:\test JDBCPostgreSQLExample.java

You should see:

Facebooktwittergoogle_plustumblrFacebooktwittergoogle_plustumblr

Facebooktwittergoogle_plustumblrFacebooktwittergoogle_plustumblr

Leave a Reply

Your email address will not be published.

Самоучители--узнать детальнее--