Skip to content

Instantly share code, notes, and snippets.

@biswarupadhikari
Created July 30, 2012 06:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save biswarupadhikari/3205405 to your computer and use it in GitHub Desktop.
Save biswarupadhikari/3205405 to your computer and use it in GitHub Desktop.
How to insert Data Into Mysql In JSP
<%@page import="java.sql.*"%>
<%@page import="com.mysql.jdbc.PreparedStatement"%>
<%@page import="com.mysql.jdbc.Connection"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
Connection con;
Class.forName("com.mysql.jdbc.Driver");
con=(Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/java", "java", "123456");
PreparedStatement ps=(PreparedStatement)con.prepareStatement("INSERT INTO users(username,password) VALUES('user1','123456')");
ps.executeUpdate();
%>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment