Skip to main content

java program insert record using PreparedStatement


java program insert  record  using  PreparedStatement

java MS ACCESS  insert,update  delete using  PreparedStatement





import java.sql.*;

class InsertPs
{
public static void main(String s[])
{
try{
int id=Integer.parseInt(s[0]);
String nm=s[1];

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:demodb");

PreparedStatement psmt=con.prepareStatement("insert into demo(id,dname)values(?,?)");

psmt.setInt(1,id);
psmt.setString(2,nm);

int result=psmt.executeUpdate();
System.out.println("record Inserted"+result);
con.close();


}
catch(Exception e)
{System.out.println(""+e);}



}


}







Learn Delete record from MS ACCESS USING PREPAIRED STATEMENT CLICK HERE





  • insert query in java using prepared statement
  • how to insert values into table in mysql using java
  • how to use preparedstatement in java for select query
  • jdbc preparedstatement insert multiple records
  • how to insert values into table in mysql using java in eclipse
  • jdbc insert statement with variables
  • insert query in java using statement
  • how to insert values into table in mysql using java in netbeans

Labels

Show more

Popular posts from this blog

Basic java

java java java, learn java online free, classroom java tutorial, beginners java, java beginners, java programming,  basic java , basic java Tutorial,  basic java  Assignment           Hello friends ,       I am learning Basic java . my motive behind this blog is to help those want to learn Basic java online free of cost and grab each and every basic aspect of java programming .     you can find java tutorial from basic on this blog i will post each and every assignment of basic java with source code .          we will divide our course  in to Day work .          Let's start Day One  Basic Java Assignment for  Beginners      Basic Requirement to learn Java Programming Download following software             1. Text Editor (Notepad, Notepad++, Edit pad, Eclipse...

java read file Character by Character

welcome java file handling tutorial . in this tutorial we are going to learn how to read text file using  java here i have used FileReader to  read file Character by Character. use following steps to read text file using java  program 1. create one folder on d drive as f that is name of folder is f 2. create t1.txt file write some text on it 3. create java program use following code or follow steps from video save java program in same folder import java.io.* package properly in java program 4. compile program and run 5. to understand program read what is FileReader read program explanation given below. save RfileCh.java // program by Prakash import java.io.*; class RfileCh {  public static void main(String s[])  {   try{        FileReader r=new FileReader("t1.txt");   // used to open a file   int ch;     while((ch=r.read())!=-1)   // here -1 is end of ...

Java Program to delete record using JFrame and Prepaired Statement

Java Program to delete record using JFrame and Prepaired Statement Here is table Design  Create table demo using two column as id  and Dname , id is primary key  Program source code  +import javax.swing.*;   import java.awt.event.*;   import java.sql.*; public class FrameDelete extends JFrame implements ActionListener{       JTextField tf1,tf2,tf3;       JButton b1,b2;   JLabel l1,l2; Connection con;    PreparedStatement psmt;   int result; //declaration of control    FrameDelete(){           JFrame f= new JFrame("InsertDemo");   // l1=new JLabel("Enter RollNo"); l1.setBounds(150,10,150,50);         tf1=new JTextField();           tf1.setBounds(150,50,150,20);   tf3=new JTextField();           tf3.setBounds(1...