Skip to content

Instantly share code, notes, and snippets.

@luckydev
Created May 11, 2014 06:06
Show Gist options
  • Save luckydev/138643c8905a1bcaf0f4 to your computer and use it in GitHub Desktop.
Save luckydev/138643c8905a1bcaf0f4 to your computer and use it in GitHub Desktop.
My first pieces of web db code. Without ORM. or ActiveRecord.
public void addAComment(Comment c) throws Exception{
openConnection();
Statement st = connection.createStatement();
String query = "insert into comments (comment,personid,personname,issueid,commenton,companyid) " +
"values('"+c.getComment()+"',"+c.getPersonid()+",'"+c.getPersonname()+"',"+c.getIssueid()+",'"+c.getCommenton()+"',"+c.getCompanyid()+")";
st.execute(query);
System.out.println("====Comment added");
closeConnection();
}
public void deleteAComment(int id) throws Exception{
openConnection();
Statement st = connection.createStatement();
String query = "delete from comments where commentid="+id;
st.executeUpdate(query);
System.out.println("=====Comment deleted");
closeConnection();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment