I'm very new to web-application programming with Java. I have two questions.
First: I have a postgresql database. I can access the database fine when doing it outside of a servlet (as a JUnit4 test). However, when I try to access it via a servlet I get:
java.sql.SQLException: No suitable driver found for jdbc:postgresql://localhost:5432/comic_store
at java.sql.DriverManager.getConnection(DriverManager.java:602)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at ilya.database.DBService.<clinit>(DBService.java:15)
at ilya.database.UserGateway.getUserByEmail(UserGateway.java:29)
at ilya.controller.Login.<init>(Login.java:12)
etc. Why would this exception get thrown while accessing from a servlet, but not otherwise.
Second: What is the preferred way of initializing a database connection in servlets? Should I be creating a DataSource with web.xml?