Skip to main content

Posts

Showing posts with the label JDBC Sample PostgreSQL

JDBC PostgreSQL Example

Hi , Here are the steps, how to configure the JDBC with PostgreSQL/PostgresPlus. JDBC PostgreSQL =============== Step 1 ====== Download the postgreSQL jdbc diver. Step 2 ====== cp the file location to /opt/PostgreSQL/9.1/lib Step 3 ====== Create the following JavaTest.java @/opt/PostgreSQL/9.1 import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; public class JavaTest { public static void main(String[] args) throws ClassNotFoundException, SQLException{ Class.forName("org.postgresql.Driver"); Connection con = DriverManager.getConnection("jdbc:postgresql://127.0.0.1:5432/postgres", "postgres", "postgres"); PreparedStatement ps = con.prepareStatement("SELECT RELNAME,RELFILENODE FROM PG_CATALOG.PG_CLASS"); //String oldestDate = "20120101"; //ps.setString(1, oldestDate); System.out.println(...