//STEP 1. Import required packages
import java.sql.Connection ;
import java.sql.DriverManager ;
import java.sql.SQLException ;
import java.sql.Statement ;
class JDBCExample {
static final String DB_URL
= "jdbc:mysql://localhost/TUTORIALSPOINT" ; static final String USER
= "guest" ; static final String PASS
= "guest123" ;
public static void main
( String [ ] args
) { // Open a connection
) {
// Execute a query
System .
out .
println ( "Inserting records into the table..." ) ; String sql
= "INSERT INTO Registration VALUES (100, 'Zara', 'Ali', 18)" ; stmt.executeUpdate ( sql) ;
sql = "INSERT INTO Registration VALUES (101, 'Mahnaz', 'Fatma', 25)" ;
stmt.executeUpdate ( sql) ;
sql = "INSERT INTO Registration VALUES (102, 'Zaid', 'Khan', 30)" ;
stmt.executeUpdate ( sql) ;
sql = "INSERT INTO Registration VALUES(103, 'Sumit', 'Mittal', 28)" ;
stmt.executeUpdate ( sql) ;
System .
out .
println ( "Inserted records into the table..." ) ; e.printStackTrace ( ) ;
}
}
}
Ly9TVEVQIDEuIEltcG9ydCByZXF1aXJlZCBwYWNrYWdlcwppbXBvcnQgamF2YS5zcWwuQ29ubmVjdGlvbjsKaW1wb3J0IGphdmEuc3FsLkRyaXZlck1hbmFnZXI7CmltcG9ydCBqYXZhLnNxbC5TUUxFeGNlcHRpb247CmltcG9ydCBqYXZhLnNxbC5TdGF0ZW1lbnQ7CgogY2xhc3MgSkRCQ0V4YW1wbGUgewogICBzdGF0aWMgZmluYWwgU3RyaW5nIERCX1VSTCA9ICJqZGJjOm15c3FsOi8vbG9jYWxob3N0L1RVVE9SSUFMU1BPSU5UIjsKICAgc3RhdGljIGZpbmFsIFN0cmluZyBVU0VSID0gImd1ZXN0IjsKICAgc3RhdGljIGZpbmFsIFN0cmluZyBQQVNTID0gImd1ZXN0MTIzIjsKCiAgIHB1YmxpYyBzdGF0aWMgdm9pZCBtYWluKFN0cmluZ1tdIGFyZ3MpIHsKICAgICAgLy8gT3BlbiBhIGNvbm5lY3Rpb24KICAgICAgdHJ5KENvbm5lY3Rpb24gY29ubiA9IER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