java jdbc
java jdbc
*;
while(rs.next()) {
System.out.println("Id is " + rs.getInt(1));
System.out.println("Name is " + rs.getString(2));
System.out.println("Salary is " + rs.getInt(3));
}
con.close();
}
//insert query
public static void insertRecord() throws Exception{
String url = "jdbc:mysql://localhost:3306/jdbcdemo";
String userName = "root";
String passWord = "Test";
String query = "insert into employee values (4,'priya',250000)";
int id=5;
String name = "Varun";
int salary = 300000;
int id=6;
String name = "Nila";
int salary = 300000;
//delete
public static void delete() throws Exception{
String url = "jdbc:mysql://localhost:3306/jdbcdemo";
String userName = "root";
String passWord = "Test";
int id=5;
//update
public static void update() throws Exception{
String url = "jdbc:mysql://localhost:3306/jdbcdemo";
String userName = "root";
String passWord = "Test";
//Types of statement
//normal statement
//prepared statement
//callable statement call GetEmp()
while(rs.next()) {
System.out.println("Id is " + rs.getInt(1));
System.out.println("Name is " + rs.getString(2));
System.out.println("Salary is " + rs.getInt(3));
}
con.close();
}
while(rs.next()) {
System.out.println("Id is " + rs.getInt(1));
System.out.println("Name is " + rs.getString(2));
System.out.println("Salary is " + rs.getInt(3));
}
con.close();
}
cst.executeUpdate();
System.out.println(cst.getString(2));
con.close();
}
//commit vs autocommit
public static void commitdemo() throws Exception{
String url = "jdbc:mysql://localhost:3306/jdbcdemo";
String userName = "root";
String passWord = "Test";
con.close();
//batch processing
for(int i: res) {
if(i>0)
continue;
else
con.rollback();
}
con.commit();
con.close();