Java program does not check SQLite Constraint?
I have to following table structure and their content
create table Parent
(
ParentID int primary key,
ParentName varchar(30)
)
create table child
(
ChildID int primary key,
ParentID int references Parent,
ChildName varchar(30)
)
insert into Parent values(1,'a');
insert into Parent values(2,'b')
insert into Child values(1,1,'c');
insert into Child values(2,1,'d');
insert into Child values(3,1,'e');
insert into Child values(4,1,'f');
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.List;
public class LiteConn {
public static void main(String[] args) throws SQLException {
// TODO Auto-generated method stub
Connection con=null;
Statement st=null;
ResultSet rs=null;
try {
Class.forName("org.sqlite.JDBC");
con= DriverManager.getConnection("jdbc:sqlite:C:\\Users\\chaitanya\\Documents\\Demo.db");
st = con.createStatement();
int i=st.executeUpdate("delete from Parent where ParentID=1 ");
System.out.println("i "+i);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println(e.getMessage());
}
catch(ClassNotFoundException e1)
{
System.out.println(e1.getMessage());
}
finally {
con.close();
}
}
}
**
SQLite IDE does not allow to fire this query but when I try this through Java program, this query execute.
(This delete query trying to delete parent row....)**