import java.io.*; import java.sql.* ;
class JDBCInsert{ public static void main( String args[] ){ try{ Class.forName("com.mysql.jdbc.Driver"); Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/dbName","root", "root") ; Statement stmt = conn.createStatement() ; int rows = stmt.executeUpdate("INSERT INTO tableName VALUES (4, 'sandeep')"); System.out.println(rows + " Rows modified") ; stmt.close() ; conn.close() ; } catch(SQLException se) { System.out.println("SQL Exception:"+se) ; } catch(Exception e){ System.out.println(e) ; } } }
|
This is the good example to understand for insert query......
ReplyDeleteGood Blog
This is the good example to understand about jdbc insert query for java developers
ReplyDeleteGood Blog for Java Programmer..
I am appreciating you Nice...