+ 2
What is the difference between createStatement and prepareStatement method in JAVA?
Hi guys, I am trying to learn JDBC and I am watching some tutorials and reading some information; however, I am little confused about this topic since I have watch two different methods of executing a query. The following are: Method I: Connection conn = DBUtil.getConnection(DBType.MYSQL); Statement stmt = conn.createStatement(); Method II: Connection conn = DBUtil.getConnection(DBType.MYSQL); PreparedStatement stmt = conn.prepareStatement(sql); From these methods, I really want to fully understand their differences. Please if you can explain me their difference using your own words. Also, I do not understand why Sololearn does not include JDBC in its JAVA lesson since it has already a lesson about SQL.
1 ответ
+ 1
I'm no expert,so someone wiser will correct this,but I think that the difference is that with create statement you use a sentence created from your own app,and, with prepared statement,you call a sentence already created from your sql server