Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- import java.io.IOException;
- import java.io.PrintWriter;
- import javax.servlet.ServletException;
- import javax.servlet.annotation.WebServlet;
- import javax.servlet.http.HttpServlet;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- /**
- *
- * @author User_30
- */
- @WebServlet(urlPatterns = {"/NewServlet"})
- public class NewServlet extends HttpServlet {
- /**
- * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
- * methods.
- *
- * @param request servlet request
- * @param response servlet response
- * @throws ServletException if a servlet-specific error occurs
- * @throws IOException if an I/O error occurs
- */
- protected static Connection initializeDatabase()
- throws SQLException, ClassNotFoundException {
- String dbDriver="com.sql.jdbc.Driver";
- String dbURL= "jdbc:mysql://localhost:3306/test?zeroDataBehavior=converttoNull";
- Class.forName(dbDriver);
- Connection con=DriverManager.getConnection(dbURL,"root","");
- out.println("<html><body><b>Successfully connected"+ "</br></body></html>");
- return con;
- }
- }
- }
Add Comment
Please, Sign In to add comment