Greetings everyone and thank you for checking out my post. I am trying to connect my servlet with my database by using the Mysql jdbc driver. My .jar from mysql jdbc driver is in the folder apache-tomcat-7.0.27/lib . MyServlet is a servlet and i have SQL.java in the same folder where connection must established.
private static Connection conn = null;
Class.forName(driver).newInstance();
conn = (Connection)
DriverManager.getConnection("jdbc:mysql://"+"localhost:3306"+"/"+ "ergasia3", "root" , "spiros");`
Unfortunately, when i try to do this, i have an error :com.mysql.jdbc.Driver .
Here's my web.xml
<web-app>
<display-name>WebApp01</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>MyServlet</servlet-name>
<servlet-class>com.srk.pkg.MyServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>MyServlet</servlet-name>
<url-pattern>/MyServlet.do</url-pattern>
</servlet-mapping>
<resource-ref>
<description>database</description>
<res-ref-name>jdbc/ergasia3</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
and now my context.xml
<Context path="/ergasia3" docBase="ergasia3"
debug="5" reloadable="true" crossContext="true">
<Resource name="jdbc/ergasia3" auth="Container"
type="javax.sql.DataSource"
user="root" password="spiros"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/ergasia3"
maxActive="15" maxIdle="3" />
</Context>