Advertisement
Guest User

Untitled

a guest
Dec 12th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.98 KB | None | 0 0
  1. <%@page import="java.sql.*"%>
  2.  
  3. <%@page contentType="text/html" pageEncoding="UTF-8"%>
  4. <!DOCTYPE html>
  5. <html>
  6.     <head>
  7.         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  8.         <title>JSP Page</title>
  9.     </head>
  10.     <body>
  11.         <h1>Hello World!</h1>
  12.        
  13.         <%@ page language="java" import="java.util.*" import = "java.sql.DriverManager" import="java.sql.Connection" %>
  14. <%
  15.        
  16.    
  17.        
  18. //        Class.forName("com.mysql.jdbc.Driver");
  19. //        String url = "jdbc:mysql://localhost:3306/BazaPracownikow";
  20.        
  21.        
  22.         String url = "jdbc:mysql://localhost:3306/bazapracownikow";
  23.         String user = "root";
  24.         String password = "";
  25.         Class.forName("com.mysql.jdbc.Driver");
  26.         Connection con = DriverManager.getConnection(url, user, password);
  27.         Statement stmt = con.createStatement();
  28.  
  29.         ResultSet result = stmt.executeQuery("select * from pracownicy");
  30.         ResultSetMetaData meta = result.getMetaData();
  31.        
  32.         String imie = request.getParameter("imie");
  33.         String nazwisko = request.getParameter("nazwisko");
  34.         String PESEL = request.getParameter("pesel");
  35.         String miejscowosc = request.getParameter("miejscowosc");
  36.         String kod_pocztowy = request.getParameter("kod_pocztowy");
  37.  
  38.         //tutaj walidacja
  39.         //
  40.        
  41.  
  42.  
  43.  
  44. //            String query = "INSERT INTO pracownicy (imie, nazwisko, PESEL, miejscowosc, kod_pocztowy) VALUES "
  45. //                    + "("
  46. //                    + imie + ", "
  47. //                    + nazwisko + ", "
  48. //                    + PESEL + ", "
  49. //                    + miejscowosc + ", "
  50. //                    + kod_pocztowy +
  51. //                    " )";
  52.            
  53.  
  54.  String query = "INSERT INTO pracownicy (imie, nazwisko, PESEL, miejscowosc, kod_pocztowy) VALUES ('imie', 'nazwisko' ,'PESEL', 'miejscowosc', 'kod')";
  55.  
  56.             stmt.executeUpdate(query);  
  57.        
  58. %>
  59.     </body>
  60. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement