|
How to insert data using JDBC |
|
|
executeUpdate() method of the Statement object is used to update a table in the database. This sample code first make a JDBC connection to the database and then insert a row in employee table.
import java.sql.*;
public class InsertValue {
public static void main(String[] args) {
String url = " jdbc:odbc:dumy ";
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:dumy"; "sa", "");
Statement stmt = con.createStatement();
stmt.executeUpdate("insert into employee " + "values(1,'R',5500 )");
}
catch( Exception e ) {
e.printStackTrace();
return;
}
}
}
|
Related Tips
|
Page 1 of 0 ( 0 comments )
You can share your information about this topic using the form below!
Please do not post your questions with this form! Thanks.