This week's giveaway is in the Testing forum.
We're giving away four copies of TDD for a Shopping Website LiveProject and have Steven Solomon on-line!
See this thread for details.
Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Updating a SQL Database

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
author & internet detective
Posts: 41073
848
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 41073
848
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 2407
36
Scala Python Oracle Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
     
    Ranch Hand
    Posts: 211
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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.
     
    Bartender
    Posts: 322
    24
    Eclipse IDE Firefox Browser
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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
     
    Rancher
    Posts: 43027
    76
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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/
     
    Today's lesson is that you can't wear a jetpack AND a cape. I should have read this tiny ad:
    free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
    https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
    reply
      Bookmark Topic Watch Topic
    • New Topic