postgres.cs.wisc.edu. This is being offered for a few reasons.
bbadger requests a user named bbadger-project to work in the database bbadger_db.
$ /s/postgresql/bin/psql -h postgres.cs.wisc.edu -p 5432 bbadger_db ... => select current_user; current_user -------------- bbadger (1 row)The user is
bbadger. To become the user bbadger-project, simply issue the following command. Please note that the quotes are important in the following example because of the dash in the user name.
=> set role to "bbadger-project"; SET => select current_user; current_user ----------------- bbadger-project (1 row)Now the user is
bbadger-project, and commands can be issued as bbadger-project, including setting/resetting its password.
=> alter user "bbadger-project" password '[password]'; ALTER ROLE
/s/postgresql/bin/psql -h postgres.cs.wisc.edu -p 5432 -U bbadger-project bbadger_db Password for user bbadger-project:
$dbh = DBI->connect("dbi:Pg:dbname=bbadger_db;host=postgres.cs.wisc.edu;port=5432", "bbadger-project", "[password]");
Please consult proper documentation on how to connect with a password using the interface of your choice.
CLASSPATH environment variable to include /s/postgresql/java/postgresql.jar.
For example, you can run this command or add it to your .bashrc.local or .cshrc.local file:
export CLASSPATH=/s/postgresql/java/postgresql.jar:$CLASSPATH:. (bash/ksh) setenv CLASSPATH /s/postgresql/java/postgresql.jar:$CLASSPATH:. (tcsh/csh) Here's a simple example program showing how to connect using the JDBC.
import java.sql.*; // import the JDBC
import java.util.*;
public class Jdbc {
public static void main (String[] args) {
try {
Class.forName("org.postgresql.Driver"); // Load the PostgreSQL JDBC driver
// Connect to the database, the SSL lines are required to connect.
Properties props = new Properties();
props.setProperty("user", "bbadger-project");
props.setProperty("password", "[password]");
props.setProperty("ssl", "true");
props.setProperty("sslfactory", "org.postgresql.ssl.NonValidatingFactory");
Connection conn = DriverManager.getConnection("jdbc:postgresql://postgres.cs.wisc.edu:5432/bbadger_db", props);
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery("select col1 from my_table");
while (rs.next()) {
System.out.print("Row returned: ");
System.out.println(rs.getString(1));
}
// close up shop
rs.close();
st.close();
conn.close();
} catch (Throwable ex) {
System.err.println("Uncaught exception in main...");
ex.printStackTrace();
}
}
}
More information can be found at the following locations:
GRANT and REVOKE SQL statements.
GRANT "bbadger-project" TO bucky;
Now the user bucky is a member of this user/group and has the privilege to run queries with the same permissions as bbadger-project, and you didn't have to add another user to your table's permissions.
REVOKE "bbadger-project" FROM bucky;
bucky is no longer a member of this user/group and can no longer use the same permissions as bbadger-project. bucky will still be able to access any database objects with permissions granted directly to him or other groups he is a member of.
SET their role and run commands as that user, or simply to run commands with the same permissions of that user. If a user has DELETE privileges on a table, any member of that user can delete data from a table or remove said table. Any member can also GRANT or REVOKE privileges on database objects by setting their role to that user.
Moreover, if you include WITH GRANT OPTION when you GRANT membership, you then allow that member to manage membership in said user. They can then in turn GRANT membership to others without your consent, or they could REVOKE your membership and cause you to lose the ability to properly manage your user.
This is a very powerful tool, but it comes with some rather significant gotchas. Keep in mind that whoever requests the role will be considered responsible for its usage. Please be careful about how and to whom you grant membership privileges.
postgres.cs.wisc.edu is still handled by Kerberos. You do not need to set or use a password to connect.
Keep in mind that your normal login cannot be used as a group per above, and that use of the JDBC and other non-Kerberos-aware interfaces will not work with your normal username and login.