Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 11 of 11

Thread: Create read-only data

  1. #1
    Junior Member
    Join Date
    Jul 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Create read-only data

    hello,

    i want me to write a small cash register system, which save the sold products. At the moment i use derby db embedded.

    Now my problem is:
    i must save these data read-only because of legal reasons. Nobody should be allowed to update or delete these data.

    I have no idee how can solve this problem.

    User restrictions don't help me, because i can give me all rights at any moment, because i'm the admin.

    i hope that anyone can help me.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,552
    Thanks
    45
    Thanked 1,953 Times in 1,927 Posts

    Default Re: Create read-only data

    Is this a java programming problem
    or a database problem or file system problem?

  3. #3
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 286 Times in 225 Posts
    Blog Entries
    4

    Default Re: Create read-only data

    I don't have much experience with Derby DB. Are users able to open these databases outside of the application?
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

    Looking for a Java job? Visit - Java Programming Careers

  4. #4
    Junior Member
    Join Date
    Jul 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Create read-only data

    Quote Originally Posted by Norm View Post
    Is this a java programming problem
    or a database problem or file system problem?
    I think it is a programming problem, because as owner of the db i can give always all rights.

    Quote Originally Posted by JavaPF View Post
    I don't have much experience with Derby DB. Are users able to open these databases outside of the application?
    If you know the user and password you are able to open a connection outside of the application.

    My application only has one user and doesn't provide any possibility to update these data. But if you open a direct db connection, you are able to execute all sql cmds.

    It wouldn't help me if I restrict this user or these tables, because i am the admin and i can give me all right at any moment.

    Therefore there are any component which would help me to create read-only data?

  5. #5
    Super Moderator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,097
    Thanks
    169
    Thanked 779 Times in 725 Posts
    Blog Entries
    5

    Default Re: Create read-only data

    Quote Originally Posted by marky8264 View Post
    My application only has one user and doesn't provide any possibility to update these data. But if you open a direct db connection, you are able to execute all sql cmds.

    It wouldn't help me if I restrict this user or these tables, because i am the admin and i can give me all right at any moment.

    Therefore there are any component which would help me to create read-only data?
    Never used Derby, but I'm guessing like other databases you should be able to create a new user and grant only the permissions necessary to this user (in your case read only - this should be done regardless: its always recommended that you shouldn't be allowing clients to access a database as the root user). Your client then accesses the database using this new username/password

  6. #6
    Junior Member
    Join Date
    Jul 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Create read-only data

    Quote Originally Posted by copeg View Post
    Never used Derby, but I'm guessing like other databases you should be able to create a new user and grant only the permissions necessary to this user (in your case read only - this should be done regardless: its always recommended that you shouldn't be allowing clients to access a database as the root user). Your client then accesses the database using this new username/password
    If i create a new restricted user nevertheless i always have the possibility to update these data.
    My problem is:
    I am the admin and i must write a system, which restrict my rights.
    I should not be able to edit these data.

    The other users have no possibility to edit, because the application doesn't provide any way of manipulation.

    Give there are any component, which solve my problem, or another way?

  7. #7
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,552
    Thanks
    45
    Thanked 1,953 Times in 1,927 Posts

    Default Re: Create read-only data

    i must save these data read-only
    There is a contradiction here. If you are saving the data, then you must have write authority.
    Some one must have update authority.

    If the data were saved in a simple file, you could set the R/O flag for the file to prevent it being accidentally updated.
    But if you can set the R/O flag on, you can set it off.
    I don't know of a WRITE-ONCE flag or option.

  8. #8
    Super Moderator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,097
    Thanks
    169
    Thanked 779 Times in 725 Posts
    Blog Entries
    5

    Default Re: Create read-only data

    Quote Originally Posted by marky8264 View Post
    If i create a new restricted user nevertheless i always have the possibility to update these data.
    My problem is:
    I am the admin and i must write a system, which restrict my rights.
    I should not be able to edit these data.

    The other users have no possibility to edit, because the application doesn't provide any way of manipulation.

    Give there are any component, which solve my problem, or another way?
    I'm still not entirely sure I understand the problem, but I'll recommend the solution again: create a new user and restriction the permissions. You should be able to restrict the permissions to INSERT only to prevent any updates or deletes. Then if you as root user are afraid to alter the data, access the database as this user.

  9. #9
    Junior Member
    Join Date
    Jul 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Create read-only data

    Quote Originally Posted by Norm,15251
    There is a contradiction here. If you are saving the data, then you must have write authority.
    Some one must have update authority.

    If the data were saved in a simple file, you could set the R/O flag for the file to prevent it being accidentally updated.
    But if you can set the R/O flag on, you can set it off.
    I don't know of a WRITE-ONCE flag or option.
    That is my problem, i must create these data.
    That means, the only way i can solve my problem is to save these data on WORMs?

    Quote Originally Posted by copeg View Post
    I'm still not entirely sure I understand the problem, but I'll recommend the solution again: create a new user and restriction the permissions. You should be able to restrict the permissions to INSERT only to prevent any updates or deletes. Then if you as root user are afraid to alter the data, access the database as this user.
    But this solution doesn't solve my problem, because i have the possibility to use the root user to edit these data.

    My problem is a have always the possibility to edit these data. Therefore i must limit my own rights.
    Is this possible?

    Sry for my bad English, i am not good at English, but i give my best. I hope you can understand me.

  10. #10
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,552
    Thanks
    45
    Thanked 1,953 Times in 1,927 Posts

    Default Re: Create read-only data

    Require two passwords and hire an armed guard to be the only one with the other password.

  11. #11
    Super Moderator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,097
    Thanks
    169
    Thanked 779 Times in 725 Posts
    Blog Entries
    5

    Default Re: Create read-only data

    Quote Originally Posted by marky8264 View Post
    That is my problem, i must create these data.
    That means, the only way i can solve my problem is to save these data on WORMs?



    But this solution doesn't solve my problem, because i have the possibility to use the root user to edit these data.

    My problem is a have always the possibility to edit these data. Therefore i must limit my own rights.
    Is this possible.
    Then never log in as the root user.

Similar Threads

  1. Replies: 0
    Last Post: April 15th, 2010, 05:13 AM
  2. How to Write and Read Binary Data
    By neo_2010 in forum File Input/Output Tutorials
    Replies: 3
    Last Post: January 4th, 2010, 01:38 PM
  3. Read data from text file
    By yroll in forum Algorithms & Recursion
    Replies: 4
    Last Post: December 31st, 2009, 12:40 AM
  4. how to create exe jar
    By ttsdinesh in forum Java Theory & Questions
    Replies: 1
    Last Post: September 27th, 2009, 08:21 AM