VB icon

Database Connection in JSP and MySQL

Email
Submitted on: 7/25/2015 2:27:14 AM
By: Jake R. Pomperada  
Level: Advanced
User Rating: Unrated
Compatibility: Java (JDK 1.2), Java (JDK 1.5)
Views: 4341
author picture
 
     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.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
//**************************************
// 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
//**************************************

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>


Other 71 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Advanced category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.