Monday, January 13, 2014

Java JDBC programming Example 11

//Note: create  a DSN in the name of sql that is pointing the table name limbs in the database with three String column  names things,legs,arms

//PreparedAtatement  insert sql
import java.sql.*;
class Jdbc11{
public static void main(String...arg) throws Exception{
         Connection c =  DriverManager.getConnection("jdbc:odbc:sql");
         PreparedStatement pstmt = c.prepareStatement
                                                  ("insert into limbs (things,legs,arms) values (?,?,?)");

        int i = pstmt.executeUpdate();
        System.out.println("No of records updated    :"+i);

No comments: