Example for JSP MySQL connection

< Back to the Title Topic

Example for JSP MySQL connection

 JavaServer Pages (JSP) is a Java standard technology that enables you to write dynamic, data-driven pages for your Java web applications.  Below is the example of  MySQL database access using JSP.

<%@ page import = “java.sql.*”%>Obtaining a Connection

 

 

<%

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://127.0.0.1:3306/mystudyr_vshare1”,

   “mystudyr_test”,”passw0rd”);

  out.write(“Connected!”);

}

catch(SQLException e) {

  System.out.println(“Error!!!!!!” + e);

}

 

%>

Previous Optimising MySQL databases in DirectAdmin
Next How to Disable Plugin Without Going Into WordPress Admin