❮ Previous Next ❯

PreparedStatement Interface In JDBC

Let's see a program using PreparedStatement with parameters:

import java.sql.*;
class PreparedStatementDemo
{
public static void main(String args[])throws Exception
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","system","password");
String query="insert into employee values(?,?,?)";
PreparedStatement ps=conn.prepareStatement(query);
ps.setInt(1,103);
ps.setString(2,"Sushh");
ps.setInt(3,40000);
int i=ps.execyteUpdate();
System.out.println(i+"record inserted");
conn.close();
}
}
Output
1 record inserted
❮ Previous Next ❯

Follow Us




  Tutorials

Popular Links

Contact Us

address Plot No-741,2ND Floor
Opp. Bhagabati Temple,Jayadev Vihar
      Bhubaneswar-751013
      Email: info@silantechnology.com
      Phone: 0674-2361252
address
39877, sundale dr, apt#101, Fremont, California 94538, USA
       Phone: +1(262)388-7619

facebook twitter google linked in

© 2018 Silan Technology. All Rights Reserved