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("Statement output " + ps.toString());
ResultSet rs = ps.executeQuery();
while (rs.next()) {
System.out.println("Done!!!" +rs.getString("relname"));
System.out.println("Done!!!" +rs.getString("relfilenode"));
}
}
}
Step 4
======
javac JavaTest.java
Step 5
======
java -cp .:lib/postgresql-9.1-902.jdbc4.jar JavaTest
Statement output SELECT RELNAME,RELFILENODE FROM PG_CATALOG.PG_CLASS
Done!!!rawan_update_index
Done!!!81314
Done!!!indx1
Done!!!81317
Done!!!pgbench_branches
Done!!!89526
--Dinesh
Comments
Post a Comment