Languages
[Edit]
EN

Java - how to make MySQL select query with JDBC?

19 points
Created by:
Explosssive
559

In Java it is possible to make SQL SELECT query with JDBC in following way.

Note: read this article to know how to download and install JDBC driver proper way.

1. SELECT query with JDBC examples

Edit

1.1. Simple select example 

Edit

Result:

 

1.2. SQL injection prevention example

Edit

Result:

 

2. Data base preparation

Edit

create_tables.sql file:

insert_data.sql file:

 

See also

Edit
  1. Java - how to load MySQL JDBC driver proper way?
  2. Java - how to close proper way resources / objects during MySQL queries with JDBC?
  3. Java - how to make MySQL insert query with JDBC?
  4. Java - how to make MySQL update query with JDBC?
  5. Java - how to make MySQL delete query with JDBC?
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

Java - MySQL

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join