Advertisement
Guest User

Untitled

a guest
Nov 15th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. `<%@ page import="java.sql.Connection" %>
  2. <%@ page import="java.sql.DriverManager" %>
  3. <%--
  4. Created by IntelliJ IDEA.
  5. User: KidusMT
  6. Date: 11/15/2016
  7. Time: 9:59 AM
  8. To change this template use File | Settings | File Templates.
  9. --%>
  10. <%@ page contentType="text/html;charset=UTF-8" language="java" %>
  11. <%
  12. try {
  13. String connectionURL = "jdbc:mysql://localhost:3306/jsp_database";
  14. Connection connection = null;
  15. Class.forName("com.mysql.jdbc.Driver").newInstance();
  16. connection = DriverManager.getConnection(connectionURL, "root", "");
  17. if(!connection.isClosed())
  18. out.println("Successfully connected to " + "MySQL server using TCP/IP...");
  19. connection.close();
  20. }catch(Exception ex){
  21. out.println("Unable to connect to database "+ex);
  22. }
  23. %>`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement