@WebServlet(name = "ServletBlog", urlPatterns = "/posts")
public class Servlets extends HttpServlet {
{
try {
Class.forName("com.mysql.jdbc.Driver");
}
catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try (Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3300/db","root","root");
PreparedStatement preparedStatement = null;
ResultSet resultSet = preparedStatement.executeQuery("SELECT * FROM db")) {
} catch (SQLException e) {
System.err.println("DB CONNECT ERROR");
}
в Classpath загрузил driver(в intellij idea(mysql-connector-java-5.1.39-bin.jar)) но все равно пишет "DB CONNECT ERROR"