DEV Community

realNameHidden
realNameHidden

Posted on

1 1 1 1 1

JDBC program for Delete operation

Create Table::

SQL> create table test1(eid int,ename varchar2(10));

Table created.

SQL> insert into test1 values(1,’vijay’);

1 row created.

SQL> insert into test1 values(2,’rajesh’);

1 row created.

SQL> select * from test1;

EID ENAME

— — — — — — — — — —

1 vijay

2 rajesh

SQL> commit;

Commit complete.


import java.sql.*;
class Test {
    public static void main(String[] args) throws Exception {
        //load JDBC driver
        //get connection
        Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl", "system", "tiger");
        //create statement obj
        Statement st = con.createStatement();
        //prepare and execute query
        String query = "delete from test1 where eid=2";
        int count = st.executeUpdate(query);
        if (count == 0) {
            System.out.println("No Row is deleted");
        } else {
            System.out.println(count + "Row are deleted");
        }
        con.close();
    }
}
Enter fullscreen mode Exit fullscreen mode

After Code execution

SQL> select * from test1;

EID ENAME

— — — — — — — — — —

1 vijay

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay