SlideShare a Scribd company logo
<html>
  <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>


     <form action="index.jsp" method="post">

       First Name: <input type="text" name="firstName"><br>
       Last Name: <input type="text" name="lastName"><br>
       Email Address: <input type="text" name="emailAddress"><br>



       <input type="submit" Value="Submit">
     </form>
  </body>
</html>
<%@pagecontentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.sql.*, business.User, javax.servlet.*, java.io.*, javax.servlet.http.*, java.sql.*,
java.util.*, util.SQLDBUtil" %>

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>JSP Page</title>
  </head>
  <body>
    <h1>mySQL</h1>
    <%
    User user;
       try {
          String dbUrl = "jdbc:mysql://localhost:3306/murach";
          String username = "root";
          String password = "sesame";
          String query = "SELECT * FROM murach.user";
          String userName = "";
          SQLDBUtilutil = new SQLDBUtil();



           ArrayList<User> users = new ArrayList<User>();


           //insert a new record

util.insertUser(request.getParameter("firstName"),request.getParameter("lastName"),request.getParamet
er("emailAddress"));

           Connection conn = DriverManager.getConnection(dbUrl, username, password);
           PreparedStatementps = conn.prepareStatement(query);
           Statement statement = conn.createStatement();
           ResultSetrs = statement.executeQuery(query);
           while(rs.next())
           {

              user = new User(rs.getString(2),rs.getString(3),rs.getString(4));
              users.add(user);
              //userName = user.getFirstName();
           }
           rs.close();

     Iterator it = users.iterator();
     User tempUser;

     %>
     <table cellpadding="5" cellspacing="5" border =" 1">
     <%
     while(it.hasNext())
     {
tempUser = (User) it.next();


    %>
    <tr>

      <td>First Name:</td>
      <td><%= tempUser.getFirstName() %></td>
      <td> Last Name: </td>
      <td><%= tempUser.getLastName() %></td>
      <td> Email Address: </td>
      <td><%= tempUser.getEmailAddress() %></td>
    <br>
    </tr>

    <%
      }
    %>

    </table>

    <%

      } catch (SQLException e)

      {
          for (Throwable t : e)
        t.printStackTrace();
      } finally
      {

      }

     %>
  </body>
</html>
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package business;
/**
 *
 * @author tpersson
 */
public class User {

    String firstName, lastName, emailAddress;


    public User ()
    {
    }

    public User (String first, String last, String email)
    {
      firstName = first;
      lastName = last;
      emailAddress = email;

    }

    public String getFirstName()
    {
       return firstName;
    }
    public String getLastName()
    {
      return lastName;
    }
    public String getEmailAddress()
    {
          return emailAddress;
    }

}
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package util;
importjava.sql.*;
import business.User;
import javax.servlet.*;
import java.io.*;
import javax.servlet.http.*;
import java.sql.*;
import java.util.*;
/**
 *
 * @author tpersson
 */
public class SQLDBUtil{
    String dbUrl = "jdbc:mysql://localhost:3306/murach";
    String username = "root";
    String password = "sesame";
    String query = "";
    //connection objects
    Connection conn;
    PreparedStatementps;
    Statement statement;
    publicSQLDBUtil() {
    }
    public void insertUser(String first, String last, String email)
    {
       //query = "INSERT INTO murach.user('',first, last, email)";
       query = "INSERT into murach.user (FirstName,LastName,EmailAddress) values ('" + first + "','" +
last + "','" + email + "')";
       runQuery(query);
    }
    public void updateUser(String first, String last, String email)
    {


          if(doesExist(email))
          {
               query = "UPDATE murach.user SET FirstName ='"+ first
+"',LastName='"+last+"',EmailAddress='"+email2 +"' WHERE EmailAddress='" + email +"'";
               runQuery(query);
          }
          else
          {
              //out.printLine("No record with that email address");
          }
   }
private void connectDb()
{
   try {
       conn = DriverManager.getConnection(dbUrl, username, password);
   } catch (SQLException e)
   {
   } finally
   {
   }
}
private void runQuery(String q) {
   try {
       connectDb();
       PreparedStatementps = conn.prepareStatement(query);
       Statement statement = conn.createStatement();
       ps.executeUpdate();
       conn.close();

  } catch (SQLException e) {
  } finally {
  }
}
private booleandoesExist(String email)
{
   Boolean exists = false;
   ResultSetrsCheck;
   connectDb();
   query="SELECT * FROM murach.User WHERE EmailAddress='" + email + "'";
   try
   {

        ps = conn.prepareStatement(query);
        statement = conn.createStatement();
        rsCheck = statement.executeQuery(query);
        rsCheck.last();


        if(rsCheck.getRow()>0)
        {
            exists = true;
        }

  }
  catch(SQLException e)
  {

  }
  finally
  {
     return exists;

  }
}
}

More Related Content

What's hot

jrubykaigi2010-lt-rubeus
jrubykaigi2010-lt-rubeusjrubykaigi2010-lt-rubeus
jrubykaigi2010-lt-rubeus
Takeshi AKIMA
 
Idoc script beginner guide
Idoc script beginner guide Idoc script beginner guide
Idoc script beginner guide
Vinay Kumar
 
ABV_fastcontact
ABV_fastcontactABV_fastcontact
ABV_fastcontactarjun rao
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />tutorialsruby
 
Php unit the-mostunknownparts
Php unit the-mostunknownpartsPhp unit the-mostunknownparts
Php unit the-mostunknownparts
Bastian Feder
 
Database presentation
Database presentationDatabase presentation
Database presentationwebhostingguy
 
apache tajo 연동 개발 후기
apache tajo 연동 개발 후기apache tajo 연동 개발 후기
apache tajo 연동 개발 후기
효근 박
 
Intro to Jinja2 Templates - San Francisco Flask Meetup
Intro to Jinja2 Templates - San Francisco Flask MeetupIntro to Jinja2 Templates - San Francisco Flask Meetup
Intro to Jinja2 Templates - San Francisco Flask Meetup
Alan Hamlett
 
Using web2py's DAL in other projects or frameworks
Using web2py's DAL in other projects or frameworksUsing web2py's DAL in other projects or frameworks
Using web2py's DAL in other projects or frameworks
Bruno Rocha
 
Library Project Marcelo Salvador
Library Project Marcelo SalvadorLibrary Project Marcelo Salvador
Library Project Marcelo Salvador
Domingos Salvador
 
jQuery Namespace Pattern
jQuery Namespace PatternjQuery Namespace Pattern
jQuery Namespace Pattern
Diego Fleury
 
INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER
INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVERINSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER
INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER
Darwin Durand
 
5. CodeIgniter copy1
5. CodeIgniter copy15. CodeIgniter copy1
5. CodeIgniter copy1
Razvan Raducanu, PhD
 
Quebec pdo
Quebec pdoQuebec pdo
Quebec pdo
Valentine Dianov
 
Database Connectivity in PHP
Database Connectivity in PHPDatabase Connectivity in PHP
Database Connectivity in PHP
Taha Malampatti
 
14922 java script built (1)
14922 java script built (1)14922 java script built (1)
14922 java script built (1)
dineshrana201992
 
Web2py
Web2pyWeb2py
Web2py
Lucas D
 
Who killed object oriented design?
Who killed object oriented design?Who killed object oriented design?
Who killed object oriented design?
Amir Barylko
 
User controls
User controlsUser controls
User controlsaspnet123
 

What's hot (20)

jrubykaigi2010-lt-rubeus
jrubykaigi2010-lt-rubeusjrubykaigi2010-lt-rubeus
jrubykaigi2010-lt-rubeus
 
Idoc script beginner guide
Idoc script beginner guide Idoc script beginner guide
Idoc script beginner guide
 
ABV_fastcontact
ABV_fastcontactABV_fastcontact
ABV_fastcontact
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
 
Php unit the-mostunknownparts
Php unit the-mostunknownpartsPhp unit the-mostunknownparts
Php unit the-mostunknownparts
 
Introduction to php database connectivity
Introduction to php  database connectivityIntroduction to php  database connectivity
Introduction to php database connectivity
 
Database presentation
Database presentationDatabase presentation
Database presentation
 
apache tajo 연동 개발 후기
apache tajo 연동 개발 후기apache tajo 연동 개발 후기
apache tajo 연동 개발 후기
 
Intro to Jinja2 Templates - San Francisco Flask Meetup
Intro to Jinja2 Templates - San Francisco Flask MeetupIntro to Jinja2 Templates - San Francisco Flask Meetup
Intro to Jinja2 Templates - San Francisco Flask Meetup
 
Using web2py's DAL in other projects or frameworks
Using web2py's DAL in other projects or frameworksUsing web2py's DAL in other projects or frameworks
Using web2py's DAL in other projects or frameworks
 
Library Project Marcelo Salvador
Library Project Marcelo SalvadorLibrary Project Marcelo Salvador
Library Project Marcelo Salvador
 
jQuery Namespace Pattern
jQuery Namespace PatternjQuery Namespace Pattern
jQuery Namespace Pattern
 
INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER
INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVERINSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER
INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVER
 
5. CodeIgniter copy1
5. CodeIgniter copy15. CodeIgniter copy1
5. CodeIgniter copy1
 
Quebec pdo
Quebec pdoQuebec pdo
Quebec pdo
 
Database Connectivity in PHP
Database Connectivity in PHPDatabase Connectivity in PHP
Database Connectivity in PHP
 
14922 java script built (1)
14922 java script built (1)14922 java script built (1)
14922 java script built (1)
 
Web2py
Web2pyWeb2py
Web2py
 
Who killed object oriented design?
Who killed object oriented design?Who killed object oriented design?
Who killed object oriented design?
 
User controls
User controlsUser controls
User controls
 

Viewers also liked

Advanced Safe Harbor 401(K) Plan Designs (For The Financial Advisor)
Advanced Safe Harbor 401(K) Plan Designs (For The Financial Advisor)Advanced Safe Harbor 401(K) Plan Designs (For The Financial Advisor)
Advanced Safe Harbor 401(K) Plan Designs (For The Financial Advisor)raperry6073
 
partiture editi ergys estrefi
partiture editi ergys estrefipartiture editi ergys estrefi
partiture editi ergys estrefiErgys Estrefi
 
Appnotech – Developing the future
Appnotech – Developing the futureAppnotech – Developing the future
Appnotech – Developing the future
Appnotech
 
partiture illyrian demo
partiture illyrian demopartiture illyrian demo
partiture illyrian demo
Ergys Estrefi
 
Asia pacific tour... why not?
Asia pacific tour... why not?Asia pacific tour... why not?
Asia pacific tour... why not?Kamnium
 
Jenkins ユーザ・カンファレンス 2012 東京 S406-4/マルチステージ型継続的インテグレーションのすすめ
Jenkins ユーザ・カンファレンス 2012 東京 S406-4/マルチステージ型継続的インテグレーションのすすめJenkins ユーザ・カンファレンス 2012 東京 S406-4/マルチステージ型継続的インテグレーションのすすめ
Jenkins ユーザ・カンファレンス 2012 東京 S406-4/マルチステージ型継続的インテグレーションのすすめatsushi_tmx
 
WorldAffairs 2005: Meeting the Challenges of the Middle East
WorldAffairs 2005: Meeting the Challenges of the Middle EastWorldAffairs 2005: Meeting the Challenges of the Middle East
WorldAffairs 2005: Meeting the Challenges of the Middle East
World Affairs Council of Northern California
 
WorldAffairs 2012: Navigating in a Shifting Global Landscape
WorldAffairs 2012: Navigating in a Shifting Global LandscapeWorldAffairs 2012: Navigating in a Shifting Global Landscape
WorldAffairs 2012: Navigating in a Shifting Global Landscape
World Affairs Council of Northern California
 
E-Book Marketing Eleitoral
E-Book Marketing EleitoralE-Book Marketing Eleitoral
E-Book Marketing Eleitoral
Instituto Desenvolve T.I
 
мотивация власти презентация григорьева
мотивация власти презентация григорьевамотивация власти презентация григорьева
мотивация власти презентация григорьеваNick Grigoryev
 
новый покупатель Xxi века
новый покупатель Xxi векановый покупатель Xxi века
новый покупатель Xxi века
Nick Grigoryev
 
Chiude acerra , più navi per i rifiuti
Chiude acerra , più navi per i rifiutiChiude acerra , più navi per i rifiuti
Chiude acerra , più navi per i rifiuti
Elisa Leone
 

Viewers also liked (13)

Advanced Safe Harbor 401(K) Plan Designs (For The Financial Advisor)
Advanced Safe Harbor 401(K) Plan Designs (For The Financial Advisor)Advanced Safe Harbor 401(K) Plan Designs (For The Financial Advisor)
Advanced Safe Harbor 401(K) Plan Designs (For The Financial Advisor)
 
partiture editi ergys estrefi
partiture editi ergys estrefipartiture editi ergys estrefi
partiture editi ergys estrefi
 
Appnotech – Developing the future
Appnotech – Developing the futureAppnotech – Developing the future
Appnotech – Developing the future
 
partiture illyrian demo
partiture illyrian demopartiture illyrian demo
partiture illyrian demo
 
Asia pacific tour... why not?
Asia pacific tour... why not?Asia pacific tour... why not?
Asia pacific tour... why not?
 
Jenkins ユーザ・カンファレンス 2012 東京 S406-4/マルチステージ型継続的インテグレーションのすすめ
Jenkins ユーザ・カンファレンス 2012 東京 S406-4/マルチステージ型継続的インテグレーションのすすめJenkins ユーザ・カンファレンス 2012 東京 S406-4/マルチステージ型継続的インテグレーションのすすめ
Jenkins ユーザ・カンファレンス 2012 東京 S406-4/マルチステージ型継続的インテグレーションのすすめ
 
WorldAffairs 2005: Meeting the Challenges of the Middle East
WorldAffairs 2005: Meeting the Challenges of the Middle EastWorldAffairs 2005: Meeting the Challenges of the Middle East
WorldAffairs 2005: Meeting the Challenges of the Middle East
 
Library tech
Library techLibrary tech
Library tech
 
WorldAffairs 2012: Navigating in a Shifting Global Landscape
WorldAffairs 2012: Navigating in a Shifting Global LandscapeWorldAffairs 2012: Navigating in a Shifting Global Landscape
WorldAffairs 2012: Navigating in a Shifting Global Landscape
 
E-Book Marketing Eleitoral
E-Book Marketing EleitoralE-Book Marketing Eleitoral
E-Book Marketing Eleitoral
 
мотивация власти презентация григорьева
мотивация власти презентация григорьевамотивация власти презентация григорьева
мотивация власти презентация григорьева
 
новый покупатель Xxi века
новый покупатель Xxi векановый покупатель Xxi века
новый покупатель Xxi века
 
Chiude acerra , più navi per i rifiuti
Chiude acerra , più navi per i rifiutiChiude acerra , più navi per i rifiuti
Chiude acerra , più navi per i rifiuti
 

Similar to Week 12 code

Simpan data- ke- database
Simpan data- ke- databaseSimpan data- ke- database
Simpan data- ke- database
Tri Sugihartono
 
Ad java prac sol set
Ad java prac sol setAd java prac sol set
Ad java prac sol set
Iram Ramrajkar
 
Developing Applications with MySQL and Java for beginners
Developing Applications with MySQL and Java for beginnersDeveloping Applications with MySQL and Java for beginners
Developing Applications with MySQL and Java for beginners
Saeid Zebardast
 
How to Start Test-Driven Development in Legacy Code
How to Start Test-Driven Development in Legacy CodeHow to Start Test-Driven Development in Legacy Code
How to Start Test-Driven Development in Legacy Code
Daniel Wellman
 
Need help on creating code using cart. The output has to show multip.pdf
Need help on creating code using cart. The output has to show multip.pdfNeed help on creating code using cart. The output has to show multip.pdf
Need help on creating code using cart. The output has to show multip.pdf
meerobertsonheyde608
 
TypeScriptで書くAngularJS @ GDG神戸2014.8.23
TypeScriptで書くAngularJS @ GDG神戸2014.8.23TypeScriptで書くAngularJS @ GDG神戸2014.8.23
TypeScriptで書くAngularJS @ GDG神戸2014.8.23
Okuno Kentaro
 
Michael Colon Portfolio
Michael Colon PortfolioMichael Colon Portfolio
Michael Colon Portfolio
michael_colon
 
Broadleaf Presents Thymeleaf
Broadleaf Presents ThymeleafBroadleaf Presents Thymeleaf
Broadleaf Presents Thymeleaf
Broadleaf Commerce
 
SOLID Java Code
SOLID Java CodeSOLID Java Code
SOLID Java Code
Omar Bashir
 
Ex[1].3 php db connectivity
Ex[1].3 php db connectivityEx[1].3 php db connectivity
Ex[1].3 php db connectivityMouli Chandira
 
Advance Java Programs skeleton
Advance Java Programs skeletonAdvance Java Programs skeleton
Advance Java Programs skeleton
Iram Ramrajkar
 
VPN Access Runbook
VPN Access RunbookVPN Access Runbook
VPN Access RunbookTaha Shakeel
 
dfhdf
dfhdfdfhdf
Android Testing
Android TestingAndroid Testing
Android Testing
Evan Lin
 
JQuery Presentation
JQuery PresentationJQuery Presentation
JQuery Presentation
Sony Jain
 
Struts database access
Struts database accessStruts database access
Struts database access
Abass Ndiaye
 
Using database in android
Using database in androidUsing database in android
Using database in android
University of Potsdam
 
Enterprise workflow with Apps Script
Enterprise workflow with Apps ScriptEnterprise workflow with Apps Script
Enterprise workflow with Apps Scriptccherubino
 
Codemotion appengine
Codemotion appengineCodemotion appengine
Codemotion appengine
Ignacio Coloma
 

Similar to Week 12 code (20)

Simpan data- ke- database
Simpan data- ke- databaseSimpan data- ke- database
Simpan data- ke- database
 
Ad java prac sol set
Ad java prac sol setAd java prac sol set
Ad java prac sol set
 
Developing Applications with MySQL and Java for beginners
Developing Applications with MySQL and Java for beginnersDeveloping Applications with MySQL and Java for beginners
Developing Applications with MySQL and Java for beginners
 
How to Start Test-Driven Development in Legacy Code
How to Start Test-Driven Development in Legacy CodeHow to Start Test-Driven Development in Legacy Code
How to Start Test-Driven Development in Legacy Code
 
Need help on creating code using cart. The output has to show multip.pdf
Need help on creating code using cart. The output has to show multip.pdfNeed help on creating code using cart. The output has to show multip.pdf
Need help on creating code using cart. The output has to show multip.pdf
 
Practica n° 7
Practica n° 7Practica n° 7
Practica n° 7
 
TypeScriptで書くAngularJS @ GDG神戸2014.8.23
TypeScriptで書くAngularJS @ GDG神戸2014.8.23TypeScriptで書くAngularJS @ GDG神戸2014.8.23
TypeScriptで書くAngularJS @ GDG神戸2014.8.23
 
Michael Colon Portfolio
Michael Colon PortfolioMichael Colon Portfolio
Michael Colon Portfolio
 
Broadleaf Presents Thymeleaf
Broadleaf Presents ThymeleafBroadleaf Presents Thymeleaf
Broadleaf Presents Thymeleaf
 
SOLID Java Code
SOLID Java CodeSOLID Java Code
SOLID Java Code
 
Ex[1].3 php db connectivity
Ex[1].3 php db connectivityEx[1].3 php db connectivity
Ex[1].3 php db connectivity
 
Advance Java Programs skeleton
Advance Java Programs skeletonAdvance Java Programs skeleton
Advance Java Programs skeleton
 
VPN Access Runbook
VPN Access RunbookVPN Access Runbook
VPN Access Runbook
 
dfhdf
dfhdfdfhdf
dfhdf
 
Android Testing
Android TestingAndroid Testing
Android Testing
 
JQuery Presentation
JQuery PresentationJQuery Presentation
JQuery Presentation
 
Struts database access
Struts database accessStruts database access
Struts database access
 
Using database in android
Using database in androidUsing database in android
Using database in android
 
Enterprise workflow with Apps Script
Enterprise workflow with Apps ScriptEnterprise workflow with Apps Script
Enterprise workflow with Apps Script
 
Codemotion appengine
Codemotion appengineCodemotion appengine
Codemotion appengine
 

Recently uploaded

De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
Abida Shariff
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
CatarinaPereira64715
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 

Recently uploaded (20)

De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 

Week 12 code

  • 1. <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body> <form action="index.jsp" method="post"> First Name: <input type="text" name="firstName"><br> Last Name: <input type="text" name="lastName"><br> Email Address: <input type="text" name="emailAddress"><br> <input type="submit" Value="Submit"> </form> </body> </html>
  • 2. <%@pagecontentType="text/html" pageEncoding="UTF-8"%> <%@page import="java.sql.*, business.User, javax.servlet.*, java.io.*, javax.servlet.http.*, java.sql.*, java.util.*, util.SQLDBUtil" %> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> </head> <body> <h1>mySQL</h1> <% User user; try { String dbUrl = "jdbc:mysql://localhost:3306/murach"; String username = "root"; String password = "sesame"; String query = "SELECT * FROM murach.user"; String userName = ""; SQLDBUtilutil = new SQLDBUtil(); ArrayList<User> users = new ArrayList<User>(); //insert a new record util.insertUser(request.getParameter("firstName"),request.getParameter("lastName"),request.getParamet er("emailAddress")); Connection conn = DriverManager.getConnection(dbUrl, username, password); PreparedStatementps = conn.prepareStatement(query); Statement statement = conn.createStatement(); ResultSetrs = statement.executeQuery(query); while(rs.next()) { user = new User(rs.getString(2),rs.getString(3),rs.getString(4)); users.add(user); //userName = user.getFirstName(); } rs.close(); Iterator it = users.iterator(); User tempUser; %> <table cellpadding="5" cellspacing="5" border =" 1"> <% while(it.hasNext()) {
  • 3. tempUser = (User) it.next(); %> <tr> <td>First Name:</td> <td><%= tempUser.getFirstName() %></td> <td> Last Name: </td> <td><%= tempUser.getLastName() %></td> <td> Email Address: </td> <td><%= tempUser.getEmailAddress() %></td> <br> </tr> <% } %> </table> <% } catch (SQLException e) { for (Throwable t : e) t.printStackTrace(); } finally { } %> </body> </html>
  • 4. /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package business; /** * * @author tpersson */ public class User { String firstName, lastName, emailAddress; public User () { } public User (String first, String last, String email) { firstName = first; lastName = last; emailAddress = email; } public String getFirstName() { return firstName; } public String getLastName() { return lastName; } public String getEmailAddress() { return emailAddress; } }
  • 5. /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package util; importjava.sql.*; import business.User; import javax.servlet.*; import java.io.*; import javax.servlet.http.*; import java.sql.*; import java.util.*; /** * * @author tpersson */ public class SQLDBUtil{ String dbUrl = "jdbc:mysql://localhost:3306/murach"; String username = "root"; String password = "sesame"; String query = ""; //connection objects Connection conn; PreparedStatementps; Statement statement; publicSQLDBUtil() { } public void insertUser(String first, String last, String email) { //query = "INSERT INTO murach.user('',first, last, email)"; query = "INSERT into murach.user (FirstName,LastName,EmailAddress) values ('" + first + "','" + last + "','" + email + "')"; runQuery(query); } public void updateUser(String first, String last, String email) { if(doesExist(email)) { query = "UPDATE murach.user SET FirstName ='"+ first +"',LastName='"+last+"',EmailAddress='"+email2 +"' WHERE EmailAddress='" + email +"'"; runQuery(query); } else { //out.printLine("No record with that email address"); } }
  • 6. private void connectDb() { try { conn = DriverManager.getConnection(dbUrl, username, password); } catch (SQLException e) { } finally { } } private void runQuery(String q) { try { connectDb(); PreparedStatementps = conn.prepareStatement(query); Statement statement = conn.createStatement(); ps.executeUpdate(); conn.close(); } catch (SQLException e) { } finally { } } private booleandoesExist(String email) { Boolean exists = false; ResultSetrsCheck; connectDb(); query="SELECT * FROM murach.User WHERE EmailAddress='" + email + "'"; try { ps = conn.prepareStatement(query); statement = conn.createStatement(); rsCheck = statement.executeQuery(query); rsCheck.last(); if(rsCheck.getRow()>0) { exists = true; } } catch(SQLException e) { } finally { return exists; }
  • 7. } }