- Register the driver class
- Class.forName("org.postgresql.Driver");
- OR
- Resgister / Connection
param.put("user",user); param.put("password",pwd);
- c = DriverManager.getConnection(dbURL, param);
- Creating connection
c = DriverManager.getConnection ("jdbc:postgresql://localhost:5432/postgres", "postgres",
"postgre_manas9");
- Create Statement object
Statement st -null; st = con.createStatement();
- Executing queries
- Create Table : st.executeUpdate(table);
- insert data : st.executeUpdate("INSERT...
- SQL Query with ResultSet
rs = st.executeQuery("SELECT * FROM dept5");
- Closing connection:
- statement.close()
- resultset.close();
- connection.close()

|