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

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here
Sign InSign Up

SIKSHAPATH

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
Home/Questions/Q 7896
Next
In Process
Sai Chetan
  • 0
Sai Chetan
Asked: November 22, 20212021-11-22T22:24:49+05:30 2021-11-22T22:24:49+05:30In: Programming Language

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

  • 0

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

java surprise testwrite a program to differentiate between statement interface and preparedstatement interface in jdbc.
  • 1 1 Answer
  • 173 Views
  • 0 Followers
  • 0
Answer
Share
  • Facebook

    1 Answer

    • Voted
    • Oldest
    • Recent
    1. Aditya Yash
      2021-11-22T22:36:36+05:30Added an answer on November 22, 2021 at 10:36 pm
      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();

      • 0
      • Reply
      • Share
        Share
        • Share on WhatsApp
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn

    Leave an answer
    Cancel reply

    You must login to add an answer.

    Forgot Password?

    Need An Account, Sign Up Here

    Sidebar

    store ads

    Stats

    • Questions 1k
    • Answers 1k
    • Posts 149
    • Best Answers 65
    • NPTEL Probability And Statistics Week 8 Quiz Answers 2023
    • NPTEL Data Mining Assignment Answers 2023 -Week 8
    • NPTEL Data Mining Assignment Answers 2023 -Week 7
    • NPTEL Data Mining Assignment Answers 2023 -Week 6
    • NPTEL The Joy Of Computing Using Python Assignment 6 Answers Update 2023

    Explore

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

    Footer

    Sikshapath Logo

    Helpful Links

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

    Follow Us

    © 2021-23 Sikshapath. All Rights Reserved

    Insert/edit link

    Enter the destination URL

    Or link to existing content

      No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.