• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Updating a SQL Database

 
natsumi jay
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi! I had a question about updating an existing SQL database using java.
For example, pulling the list from the database, putting it in an array list (of sorts) and then editing whichever one you needed to, and "pushing" the change to the database.
I've been looking through some popular ones (Big Table, MongoDB, etc...) but haven't been able to pinpoint one.
Any suggestions?
Thanks in advance!
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm confused. Are you asking how to choose a database? It depends on your application - or what you want to learn.
 
natsumi jay
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky wrote:I'm confused. Are you asking how to choose a database? It depends on your application - or what you want to learn.


Yeah! I'm using eclipse but my problem is that all the databases that I've looked at doesn't let me change the actual database content... It won't let me "edit" existing queries.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Most people learn a relational database first (such as MySql or Postgres.) You write queries to select the data. And you write other queries to update the data. An advanced feature is a RowSet where you can update the rows and "push" back.

Once you know JDBC, you can switch to a ORM (object relational mapping) library like Hibernate. Then you select into objects directly, call the object's setters and then call update on those objects. It is good to learn the basics (raw JDBC) first so you know what the ORM library is doing behind the scenes.
 
chris webster
Bartender
Posts: 2407
33
Linux Oracle Postgres Database Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
natsumi jay wrote:Yeah! I'm using eclipse but my problem is that all the databases that I've looked at doesn't let me change the actual database content... It won't let me "edit" existing queries.

By "edit", do you mean update records in the database? The data lives in the database. If you query it in Java, you just get a copy of the data. So if you want to change the data in the database from your Java program, you need to know how to pass those changes back to the database.

  • All relational databases (MySQL, MariaDB, PostgreSQL, Oracle etc) use SQL to perform queries/inserts/updates/deletions. These are often called "CRUD" operations for Create, Read, Update, Delete.
  • If you want to execute a SQL statement from Java, you need to use a library to translate e.g. the JDBC library for your database will allow you to submit strings of SQL to be executed by your database.

  • I recommend you:

  • Find a free relational database e.g. MySQL is popular so there are lots of free tutorials, online help etc.
  • Learn a bit about how data is modeled and stored in a database e.g. find out about tables, columns, indexes.
  • Learn some basic SQL so you can play with your data and tables directly in the database.
  • Learn some basic JDBC so you can do the same thing from Java.

  • MongoDB and the other NoSQL databases are very interesting, but they are all based on different ideas about how to model and store data. If you learn a bit about how relational databases work first, you will have a chance of understanding something about the vast majority of database systems in the world today. You will also be in a better position to understand how NoSQL databases are different and why some NoSQL databases might be better for some applications but not for others.
     
    Tyson Lindner
    Ranch Hand
    Posts: 211
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I'm somewhat of a database newbie myself and have found MySQL easy to use. Its free and one package comes with MySQLWorkbench that gives you a full view of your database. So I'll have that in one window and Eclipse in the other so I can see exactly what is happening to my database whenever I change my java code.
     
    Chris Barrett
    Bartender
    Posts: 317
    24
    Eclipse IDE Firefox Browser
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Another option for a free local database is Apache Derby. For basic tutorials on the SQL commands you should know to generate ResultSets and execute Statements, check out W3Schools.

    Longer term, you might want to consider a course in SQL. SQL is very powerful when you get into the higher level functions and capabilities. I find a lot of programmers don't really understand what they can do with SQL and spend too much time making Java utility methods to compensate - - myself included...

    Cheers!
    Chris
     
    Ulf Dittmer
    Rancher
    Posts: 42969
    73
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    W3Schools
    .
    While I haven't read the SQL section of that site, at least parts of it (like the web section) are infamous for shoddy content, so I generally advise people to stay away from it: http://www.w3fools.com/
     
    It is sorta covered in the JavaRanch Style Guide.
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic