Created
May 11, 2014 06:06
-
-
Save luckydev/138643c8905a1bcaf0f4 to your computer and use it in GitHub Desktop.
My first pieces of web db code. Without ORM. or ActiveRecord.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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