Sign Up

Have an account? Sign In Now

Sign In

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

Sorry, you do not have permission to ask a question, You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here
Sign InSign Up

SIKSHAPATH

SIKSHAPATH Logo SIKSHAPATH Logo

SIKSHAPATH Navigation

  • Home
  • Questions
  • Blog
    • Computer Science(CSE)
    • NPTEL
    • Startup
  • Shop
    • Internshala Answers
Search
Ask A Question

Mobile menu

Close
Ask A Question
  • Home
  • Questions
  • Blog
    • Computer Science(CSE)
    • NPTEL
    • Startup
  • Shop
    • Internshala Answers
  • About
    1. Asked: November 22, 2021In: Programming Language

      Write a program to differentiate between Statement interface and PreparedStatement interface in JDBC.

      Aditya Yash
      Aditya Yash
      Added an answer on November 22, 2021 at 10:36 pm

      Statement : It is used for accessing your database. Statement interface cannot accept parameters and useful when you are using static SQL statements at runtime. If you want to run SQL query only once then this interface is preferred over PreparedStatement.   Example –   //Creating The StatRead more

      1. Statement :

      It is used for accessing your database. Statement interface cannot accept parameters and useful when you are using static SQL statements at runtime. If you want to run SQL query only once then this interface is preferred over PreparedStatement.

       

      Example –

       

      //Creating The Statement Object

      Statement ADI = con.createStatement();

       

      //Executing The Statement

      ADI.executeUpdate(“CREATE TABLE STUDENT(ID NUMBER NOT NULL, NAME VARCHAR)”);

      1. PreparedStatement :

      It is used when you want to use SQL statements many times. The PreparedStatement interface accepts input parameters at runtime.

       

       

      Example –

       

      //Creating the PreparedStatement object

      PreparedStatement ADI = con.prepareStatement(“update STUDENT set NAME = ? where ID = ?”);

       

      //Setting values to place holders

      //Assigns “RAM” to first place holder

      ADI.setString(1, “RAM”);

       

      //Assigns “512” to second place holder

      ADI.setInt(2, 512);

       

      //Executing PreparedStatement

      ADI.executeUpdate();

      See less
        • 0
      • Share
        Share
        • Share on WhatsApp
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn

    Sidebar

    store ads

    Stats

    • Questions 1k
    • Answers 1k
    • Posts 141
    • Best Answers 89
    • Cloud Computing Notes 101: Learn Fundamentals, Service Models, and Virtualization!
    • This Free AI Tool Translates Entire Books in Minute !
    • 25 Essential Software Testing Questions: Flashcard Edition!
    • 27 C++ Questions & Answers – Quiz 1 Flashcards
    • Interactive Alphabet Flashcards for Kids: A to Z Learning Fun!

    Explore

    • Recent Questions
    • Questions For You
    • Answers With Time
    • Most Visited
    • New Questions
    • Recent Questions With Time

    Footer

    SIKSHAPATH

    Helpful Links

    • Contact
    • Disclaimer
    • Privacy Policy Notice
    • TERMS OF USE
    • FAQs
    • Refund/Cancellation Policy
    • Delivery Policy for Sikshapath

    Follow Us

    © 2021-24 Sikshapath. All Rights Reserved