Guest User

Untitled

a guest
Feb 14th, 2020
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. import java.io.IOException;
  2. import static java.lang.System.out;
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.ResultSet;
  6. import java.sql.SQLException;
  7. import java.sql.Statement;
  8. import javax.servlet.ServletException;
  9. import javax.servlet.http.HttpServlet;
  10. import javax.servlet.http.HttpServletRequest;
  11. import javax.servlet.http.HttpServletResponse;
  12.  
  13. public class NewServlet extends HttpServlet{
  14. protected static Connection initializeDatabase()
  15. throws SQLException, ClassNotFoundException
  16. {
  17. String dbDriver = "com.mysql.jdbc.Driver";
  18. String dbURL = "jdbc:mysql://localhost:3306/test?zeroDateTimeBehavior=convertToNull";
  19. Class.forName(dbDriver);
  20. Connection con=DriverManager.getConnection(dbURL,"root","");
  21. out.println("<html><body><b>Successfully connected" + "</b></body></html>");
  22. return con;
  23. }
  24. }
Add Comment
Please, Sign In to add comment