Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to save datas in java program in SQL ?  RSS feed

 
Latif Hemid
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Some people suggest me to use SQL to save data for good. And I googled about it and I am very confused. So Can any one tell me what the SQL is? How do I save my java progrogram data in SQL? Is SQL an application to install? Example: How do I save the pgrogram's data on SQL and read them? Just suggestions and steps.
 
Tapas Chand
Ranch Hand
Posts: 614
9
BSD Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Data is stored in a Database. There are many database vendors.
Data in a database can be managed using SQL(Structured Query Language).
Using SQL we can add, delete, update or retrieve data from database.
Java provides an API which creates a bridge between the application and database and help us executing SQL on the database.

First you need to understand what RDBMS(Relational Database management System) is.
https://docs.oracle.com/javase/tutorial/jdbc/overview/database.html

Then you can go through JDBC to learn how to interact with RDBMS in Java
https://docs.oracle.com/javase/tutorial/jdbc/overview/index.html
 
ab singh
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SQL stands for structure query language, first introduced in 1985 by IBM, It is standard language for database. there are there are three type of queries made. data manipulation language(DML),data definition language(DDL), Data concurrency language (DCL). For data storage in java you have to use JDBC ODBC driver and you can use any of the database like Mysql, MS sql Server or simply MS access. For more information related to using database please use this link.Oracle page
Or else if you can use this code to understand.

 
Campbell Ritchie
Sheriff
Posts: 55351
157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good grief! What long lines! I have broken them up.
I can see duplication of information in that insert statement: you have date of birth and age, which are not independent of each other.
Why are you using so much Hungarian notation and so many underscores? The Java® convention is to avoid underscores except in constant names and package names.
 
Rob Camick
Ranch Hand
Posts: 2787
12
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't use an SQL statement like the one suggested above.

Instead, use a PreparedStatement. Much easier to code, less error prone and easier to understand and maintain.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!