//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{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c = DriverManager.getConnection("jdbc:odbc:sql");
PreparedStatement pstmt = c.prepareStatement
("insert into limbs (things,legs,arms) values (?,?,?)");
pstmt.setString(1,"dinosares");
pstmt.setInt(2,10);
pstmt.setInt(3,20);
int i = pstmt.executeUpdate();
System.out.println("No of records updated :"+i);
pstmt.close();
c.close();
}}
No comments:
Post a Comment