Results 1 to 14 of 14
- 04-08-2010, 03:06 PM #1
Database not updated in an order of the insertion of the data..!
I am actually trying to update the database (In Oracle) using jdbc...
In particulars, i have a gui that accepts data valus from the user and then inserts these values into the databases.
Now the problem is that the data is not inserted in the order of the updation of the database... i mean the entry made first should be before the entry made second.. but it is not actually happening..:(
I need the database to be updated in the order of the insertion because.. i need to fetch the entries from the very few lasts
please suggest ! thnx.The Quieter you become the more you are able to hear !
- 04-08-2010, 03:52 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,427
- Blog Entries
- 7
- Rep Power
- 17
Do you have an index on one (or more of the columns)? If so the data will most likely be fetched in that index order, otherwise no particular order is guaranteed and you have to install an index on that table (preferably on an "auto increment" column).
kind regards,
Jos
- 04-08-2010, 04:09 PM #3
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Put simply, there is no order in a database table.
It's a meaningless concept.
There is only order in a query that has an ORDER BY in it.
- 04-08-2010, 04:45 PM #4
- 04-08-2010, 05:21 PM #5
thnx for your replies..
How can i create a field of type timestamp ????????a field of type timestamp in your table
i mean i am new to databases.... and the only available types that i see in the netbeans are
NUMERIC , FLOAT, VARCHAR2, REAL, DATE, INTEGER, CHAR, SMALLINT, DECIMAL, INT, BLOB.
please help.
means.. when an entry is made to the databases then it can be updated to any of the rows?? have i understood correct ? means entry made at the 8th place in the order of entries , not necessarily will be added to the 8th place in the table.Put simply, there is no order in a database table.
JosAH can you please provide me the link where i can learn more about indexing? thnx.The Quieter you become the more you are able to hear !
- 04-08-2010, 05:28 PM #6
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,427
- Blog Entries
- 7
- Rep Power
- 17
- 04-08-2010, 05:46 PM #7
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
DATE will do you if you only need precision to the second, but TIMESTAMP will be better if you want it to (I think) milliseconds. but an id field would be better.
No. What it means is, when you insert a row into a table then the database can put it wherever it likes. There is no order. There is no such thing as "8th place". So, if I have a table with 10 rows in it, and then add another row, then do a "SELECT * FROM my_table", that new row could appear anywhere in the returned results. And each time you run it it may (very rarely) give you the rows back in a different order.
The only way to change this is to, as mentioned above, use something like an auto-generated id field (Oracle uses sequences), or (not as good) a timestamp, and then doing "SELECT * from my_table ORDER BY id" or "ORDER BY my_timestamp".
As a db term an index is something else entirely. I think Jos is referring to what I refer to above with sequences....ie an id field that is a unique (and incrementing) number.
- 04-08-2010, 05:57 PM #8
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,427
- Blog Entries
- 7
- Rep Power
- 17
- 04-08-2010, 06:02 PM #9
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Which is why I was advocating an id field.
There is no such thing as an auto-increment in Oracle, you use sequences and a regular number field.
- 04-08-2010, 06:27 PM #10
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,427
- Blog Entries
- 7
- Rep Power
- 17
- 04-08-2010, 08:31 PM #11
that's enough. in java use new java.util.Date().getTime() for your timestamp-field in the database, see the example here Insert TIMESTAMP value : Date Time Timestamp*«*Database*«*Java TutorialLast edited by j2me64; 04-08-2010 at 08:35 PM.
- 04-08-2010, 08:39 PM #12
thnx for such a wonderful link.. this is what i was actually looking for.thnx once again :)see the example here Insert TIMESTAMP value : Date Time Timestamp*«*Database*«*Java TutorialThe Quieter you become the more you are able to hear !
- 04-08-2010, 09:04 PM #13
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,427
- Blog Entries
- 7
- Rep Power
- 17
- 04-08-2010, 09:12 PM #14
Similar Threads
-
image insertion into database
By abhiN in forum JDBCReplies: 4Last Post: 01-05-2009, 05:09 AM -
Regarding Data Insertion
By adeeb in forum JDBCReplies: 1Last Post: 06-22-2008, 05:26 AM -
database insertion
By abhiN in forum New To JavaReplies: 0Last Post: 01-17-2008, 07:24 AM -
How to accurately test if timezone data is updated?
By Santhosh in forum Advanced JavaReplies: 0Last Post: 11-14-2007, 06:53 AM -
How to install tzdata2007i (updated Time zone database) in JDK 1.5.0_12-b04
By Santhosh in forum Advanced JavaReplies: 0Last Post: 11-06-2007, 02:16 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks