reset password
Author Message
cysun
Posts: 2935
Posted 11:56 Jul 11, 2015 |

Based on past experience, I can say that the most common problem in HW3 is database access errors. So go over the following if you run into such errors.

0. Review the PostgreSQL Installation and Basic Usage video on how to create databases and users.

1. Understand that not all database users can access all databases. For example, the user csjobs cannot access a database created by the user postgres by default. And access control not only exists at the database level, but also at the table (and some other schema elements like sequence, function etc.) level, which means that it's possible that a user has access to a database, but no access to some tables in the databases.

2. It's possible to create a database as one user then give access to the database (and all the tables in it) to another user, but it's rather tedious to do with the GUI. What this means is that the easiest way to make sure the csjobs user has access to the csjobs database is to create the csjobs database (and all the tables in it) as the csjobs user. In pgAdmin III, the default connection (which, unfortunately, is called a "server" instead of a "connection" in pgAdmin III) created after installing PostgreSQL will log you in as the user postgres, and as I said, any database you create through that connection will be owned by postgres and not accessible by other users. It's better to create another connection and login as the csjobs user and perform all operations as the csjobs user. To create a new connection, use the button that looks like a power plug with the tool tip "Add a connection to a server".

3. If you do run into an database error, read the error message carefully. Don't stop when you see "cannot open connection" or "cannot read resultset" - look further and see if you can find more information. Usually you'll find error messages like "cannot find user" (means you probably didn't create the user csjobs), or "authentication failed" (check your password), or "access denied" (you probably created the database/table as postgres but tried to access it as csjobs), or something more informative than just "cannot open connection".