Hi everyone,
I searched a while on the internet how to work with mvc for a school project.
I found a really great tutorial on this site. (http://www.daniweb.com/forums/thread141776.html)
This tutorial has everything that i needed.
In this tutorial the connection of the database is made by setting paramaters in de xml:
<servlet>
<servlet-name>loginServlet</servlet-name>
<servlet-class>servlet.loginServlet</servlet-class>
<init-param>
<param-name>jdbcDriver</param-name>
<param-value>com.mysql.jdbc.Driver</param-value>
</init-param>
<init-param>
<param-name>dbURL</param-name>
<param-value>jdbc:mysql://127.0.0.1:3306/cijfersysteem</param-value>
</init-param>
<init-param>
<param-name>dbUserName</param-name>
<param-value>vishant</param-value>
</init-param>
<init-param>
<param-name>dbPassword</param-name>
<param-value>vishant</param-value>
</init-param>
</servlet>
My login is working great, just like the tutorial explained.
But now i'm making another page ProfileServlet.java and i want to get info from the database and i get the following error:
SEVERE: java.sql.SQLException: No suitable driver found for
at java.sql.DriverManager.getConnection(DriverManager.java:602)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at model.DataManager.getConnection(DataManager.java:77)
at model.DataManager.getRichtingen(DataManager.java:262)
at servlet.ProfileServlet.processRequest(ProfileServlet.java:36)
at servlet.ProfileServlet.doGet(ProfileServlet.java:63)
Do i need to go in the web.xml and set the parameters for the ProfileServlet to?
For example:
<servlet>
<servlet-name>ProfileServlet</servlet-name>
<servlet-class>servlet.ProfileServlet</servlet-class>
<init-param>
<param-name>jdbcDriver</param-name>
<param-value>com.mysql.jdbc.Driver</param-value>
</init-param>
<init-param>
<param-name>dbURL</param-name>
<param-value>jdbc:mysql://127.0.0.1:3306/cijfersysteem</param-value>
</init-param>
<init-param>
<param-name>dbUserName</param-name>
<param-value>vishant</param-value>
</init-param>
<init-param>
<param-name>dbPassword</param-name>
<param-value>vishant</param-value>
</init-param>
</servlet>
Does this mean that i need to do this for every servlet? Which is not efficient.
Help needed for this please.
Thnx in advance.