JDBC Tutorial for Beginners #5 : Using PreparedStatements (MySql)

preview_player
Показать описание
In this video, I have explained how to make use of PreaparedStatement to do database operation easily and efficiently. The PreparedStatement interface is a subinterface of Statement. It is used to execute parameterized query.

Let's see the example of parameterized query:

String sql="insert into table_name values(?,?,?)";
As you can see, we are passing parameter (?) for the values. Its value will be set by calling the setter methods of PreparedStatement.

This tutorial series covers following topics
■ Connecting Java Program to MySQL Database
■ Inserting data into database
■ Fetching data from database
■ Updating an entry in database
■ Creating a table programmatically
■ Using PreparedStatements
■ Display database contents in JTable

- Genuine Coder
Рекомендации по теме
Комментарии
Автор

can we use prepared statements to retrive data from database

sahithreddy
Автор

Hello we're on the same age at the moment you're recording this video :D so maybe now you're I think 24? hahaha
PreparedStatements I think are better cause they are more secured, prevents SQL Injections something like that hahaha :D Thank you :D

but may I ask is there a way to make the insertion of the value dynamic rather than just putting the index column, cause as you've said what if the column might get transfered to a different index. So yeaaah THANK YOU FOR YOUR TUTORIAL :D

GelsYT
visit shbcf.ru