· 8 years ago · Dec 28, 2017, 06:42 AM
1void checkCreateMeth()
2 {
3 try{
4 System.out.println("Implementing the functionality of create table if not exist or not.");
5 Class.forName(JDBC_Driver);
6 con=DriverManager.getConnection(DB_URL, user, pass);
7 stmt=con.createStatement();
8 String sql="CREATE TABLE IF NOT EXISTS VGRWER(name varchar(10),stream varchar(10))";
9 int rs=stmt.executeUpdate(sql);
10 System.out.println("Value of rs is="+rs);
11 }catch(Exception e)
12 {
13 e.printStackTrace();
14 }
15 }
16
17When you are using executeupdate to create a table then your are not doing INSERT or an UPDATE so you are getting 0 as no row(s) were affected
18
19May be this link be useful :-https://stackoverflow.com/questions/18032075/executeupdate-returns-zero-despite-correct-execution