Code example for Statement

Methods: executeUpdate

0
			con = GetConnection("JunkDB");
 
			Statement stmt = con.createStatement();
 
			try { 
				stmt.executeUpdate("DROP TABLE myTable");
			} catch (SQLException e) {
				System.out.println("No existing table to delete");
			} 
 
			stmt.executeUpdate("CREATE TABLE myTable(test_id int," + "test_val char(15) not null)");
 
			stmt.executeUpdate("INSERT INTO myTable(test_id, " + "test_val) VALUES(1,'One')");
			stmt.executeUpdate("INSERT INTO myTable(test_id, " + "test_val) VALUES(2,'Two')");
			stmt.executeUpdate("INSERT INTO myTable(test_id, " + "test_val) VALUES(3,'Three')");
			stmt.executeUpdate("INSERT INTO myTable(test_id, " + "test_val) VALUES(4,'Four')");
			stmt.executeUpdate("INSERT INTO myTable(test_id, " + "test_val) VALUES(5,'Five')");
 
			stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
 
		} catch (SQLException e1) {
			e1.printStackTrace();