This looks like you have two possible places where the database connection is being established. This violates the principle of simple design: no duplication.