Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%@ page import="java.sql.*" %>
- <%@ page import="java.io.*" %>
- <%
- String url = "jdbc:mysql://localhost:3306/bigul";
- String userid = "root";
- String pass = "root";
- String name = request.getParameter("name");
- String user = request.getParameter("user");
- String password = request.getParameter("pass");
- PreparedStatement pstmt = null;
- try {
- Class.forName("com.mysql.jdbc.Driver");
- }
- catch(java.lang.ClassNotFoundException e)
- { System.err.print("ClassNotFoundException: " + e.getMessage()); }
- int updateQuery = 0;
- if(name != null && user != null && password != null)
- {
- try
- {
- Connection conn = DriverManager.getConnection(url,userid,pass);
- String queryString = "INSERT INTO info(Name,Username,Password) VALUES (?, ?, ?)";
- pstmt = conn.prepareStatement(queryString);
- pstmt.setString(1,name);
- pstmt.setString(2,user);
- pstmt.setString(3,password);
- updateQuery = pstmt.executeUpdate();
- pstmt.close();
- conn.close();
- }
- catch(Exception e){
- System.out.println(e.getMessage());
- }
- }
- %>
Add Comment
Please, Sign In to add comment