JSP Project with Database

1

I'm working on a JSP project with my driver's database not being recognized.

I'm using the following method to connect to the bank.

public ConnectionDB(){
    try {
        Class.forName("com.mysql.jdbc.Driver");

        String url = "jdbc:mysql://localhost:3306/loja";
        String user = "hxf";
        String password = "";
        con = (Connection)DriverManager.getConnection(url,user,password);

    } catch (SQLException e) {
        e.printStackTrace();
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }
}

I'm using Tomcat. The following error is returned.

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1891)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1734)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at DAO.ConnectionDB.<init>(ConnectionDB.java:13)

Does anyone have an idea what it can be?

    
asked by anonymous 15.11.2016 / 01:02

1 answer

2

Download the driver: link

Add the lib in the Tomcat LIB folder:

    
15.11.2016 / 11:03