Java examples for JDBC:Table
Inserting a Row into a Database Table
import java.awt.Graphics; import java.sql.Connection; import java.sql.SQLException; import java.sql.Statement; public class Main { public void m() { try {/* w ww . ja v a2 s.co m*/ Connection connection = null; Statement stmt = connection.createStatement(); // Prepare a statement to insert a record String sql = "INSERT INTO my_table (col_string) VALUES('a string')"; // Execute the insert statement stmt.executeUpdate(sql); } catch (SQLException e) { } } }