Advertisement
Guest User

Untitled

a guest
Apr 8th, 2017
533
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. <%@ page import="java.sql.*" %>
  2. <%@ page import="java.io.*" %>
  3. <%@page contentType="text/html" pageEncoding="UTF-8"%>
  4. <%
  5.  
  6. String connectionURL = "jdbc:mysql://localhost:3306/users";
  7. Connection connection = null;
  8. Class.forName("com.mysql.jdbc.Driver").newInstance();
  9. connection = DriverManager.getConnection(connectionURL, "root", "pass");
  10. if (!connection.isClosed()) {
  11. out.println("Connection Established");
  12.  
  13. PreparedStatement preparedStmt = connection.prepareStatement("INSERT INTO users.user_details (`Email`, `Name`, `Password`) VALUES ('ram@gmail.com', 'Ram Das', '12345678')");
  14. preparedStmt.execute();
  15. String sql="select * from user_details";
  16. PreparedStatement statement=connection.prepareStatement(sql);
  17. ResultSet rs=statement.executeQuery();
  18. if(rs.next())
  19. {
  20. System.out.println(rs.getString(1));
  21. }
  22. }
  23. connection.close();
  24. %>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement