WDD_lec_15 - Design Development Web Lec 15 1 Design Development Web More on JDBC 2 Design Development Web Example Code Executing SQL DML statements

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Web Lec - 15
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Web More on JDBC
Background image of page 2
3 Web Example Code Executing SQL DML statements
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
JDBC 4 Umair Javed©2005 Useful Statement Methods (N-I) executeQuery Executes the SQL query and returns the data in a table (ResultSet) The resulting table may be empty but never null ResultSet rs = stmt.executeQuery(“select * from table");
Background image of page 4
JDBC 5 Umair Javed©2005 Example Code 15.1 Executing SQL DML Statements /* This progarm will take two command line argument that are used to update records in the database */ import java.sql.*; //step 1 public class JdbcDmlEx { public static void main (String args [ ]){ try { //steps 2 to 5 Class.forName(“driver name”); Connection con=null; con = DriverManager.getConnection(url, usr, pwd); Statement st = con.createStatement();
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
6 Umair Javed©2005 Example Code 15.1 Executing SQL DML Statements (cont.) //Step 6: Execute the Query / DML String addVar = args[0]; String nameVar = args[1]; String sql = “UPDATE Person ” + “ SET address = ‘ “ + addVar + ” ’ ” + “ WHERE name = ‘ “ + nameVar + ” ’ ” ; int num = st.executeUpdate(sql);
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 07/01/2010 for the course CS CS506 taught by Professor mr. umair javed during the Spring '10 term at Virtual University of Pakistan.

Page1 / 20

WDD_lec_15 - Design Development Web Lec 15 1 Design Development Web More on JDBC 2 Design Development Web Example Code Executing SQL DML statements

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online