//************************************** // Name: Database Connection in JSP and MySQL // Description:In this article I would like to share with you a code to check whether JSP and MySQL is connected to one another or not. This code is very useful if you want to know if JSP and MySQL are working together. If you have some questions about programming, about my work please send mu an email at jakerpomperada@gmail.comand jakerpomperada@yahoo.com. People here in the Philippines can contact me at my mobile number 09173084360. Thank you very much and Happy Programming. // By: Jake R. Pomperada // // // Inputs:None // // Returns:None // //Assumes:None // //Side Effects:None //************************************** dbconnect.jsp <%@ page import="java.sql.*" %> <%@ page import="java.io.*" %> <html> <head> <title>Connection with mysql database</title> </head> <body> <h1>Connection status</h1> <% Connection conn=null; ResultSet result=null; Statement stmt=null; ResultSetMetaData rsmd=null; try { Class c=Class.forName("com.mysql.jdbc.Driver"); } catch(Exception e){ out.write("Error!!!!!!" + e); } try { conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/users", "root",""); out.write("Connected!"); } catch(SQLException e) { System.out.println("Error!!!!!!" + e); } %> </body> </html>