INSERT data into a database
From Progzoo
Insert a new row ('Andrew', 2753) into the table book.
The bit that runs the SQL statement is:
PreparedStatement ps = myCon.prepareStatement(
"INSERT INTO book VALUES (?,?)");
ps.setString(1,"Andrew");
ps.setInt(2,2753);
if (ps.execute()) System.out.println("Failed");
The two questions marks ? in the SQL statement represent two parameters to the statement. Parameter 1 gets set to the string 'Andrew', parameter 2 gets set to the integer 2753.
[Font]
[Default]
[Show]
[Resize]
[History]
[Profile]