aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes NX: db-2x1? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "NX: db-2x1?" Watch "NX: db-2x1?" New topic
Author

NX: db-2x1?

Nathnael Haile-Mickael
Greenhorn

Joined: Mar 15, 2004
Posts: 15
Hi Ranchers,
Sorry George, i still cannot read anything from my db-File.
have a look at my Packaging-Plan:

\main.jar -the main working directory with the runme.jar file
\classes
\code
\db-2x1_db -containing the org. zip db file + the unZipped db-2x1 file
\docs

Now my working directory is: D\:J2sdk1.4\Main.jar i got a copy of db-2x1
unzipped file, this same file i got also in \db-2x1_db folder.
Appart from that i tried to specify a path for db file:
DATEN_BANK-----Path-------D\:J2sdk1.4\Main.jar\db-2x1_db
I am not very sure if this db file is OK.
maybe it is a silly Question, but I need your opinion how i should solve this.
Thanx in advance and Regards.
Nathnael.
Chris Harris
Ranch Hand

Joined: Sep 21, 2003
Posts: 231
Hi Nathnael,
When you say you can't read the database file what do you mean. Getting an Exception of some kind? Or is there nothing in the file? You should be able to see the data using a good text editor (TextPad is a good start). Ok it will not be readable but at least you know there is data.
Chris.


SCJP 1.2, SCWCD, SCBCD
Nathnael Haile-Mickael
Greenhorn

Joined: Mar 15, 2004
Posts: 15
Hi Chris,
Yes i could see with a TextPad that there are some HEXdatas. I wrote a small programm called FileReader.java, i could copile it. But i cannot run it.
The result is that the system couldnot find the db file. Please have a look at my code on this Site, which i posted today. I dont know how to make a Link to that page, you know how i think, can you tell me how?
You see that is the problem.
Thanx
Nathnael
Chris Harris
Ranch Hand

Joined: Sep 21, 2003
Posts: 231
To add a URL to a thread do:
1) Check on the URL button
2) A box should appear.
3) Post the Link to the thread within this box
3) You will then be aksed to give the link a name (You can put any thing in here you link.
Here is a link to the thread with your code.
Code Thread
I will have a look at is code now
Chris.
Chris Harris
Ranch Hand

Joined: Sep 21, 2003
Posts: 231
Can you post in the stack trace with the message. I should be able to tell you from the path it thinks it is looking for.
Chris
Nathnael Haile-Mickael
Greenhorn

Joined: Mar 15, 2004
Posts: 15
Hi Chris,
Thank you very much for the how to Link.
Now if i did get you right about what you mean by the Stack Trace messege, have a look at this one:-

Microsoft Windows XP [Version 5.1.2600]
D:\J2sdk1.4>cd Main.jar
D:\J2sdk1.4\Main.jar>java -classpath runme.jar suncertify.db.FileReader
java.io.FileNotFoundException:
db-2x1 (Das System kann die angegebene Datei nicht finden)

at java.io.RandomAccessFile.open(Native Method)
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:200)
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:94)
at suncertify.db.FileReader.read(FileReader.java:8)
at suncertify.db.FileReader.main(FileReader.java:18)
D:\J2sdk1.4\Main.jar>

sorry it is in a German language. It just mean the system cannot find the given file (db-2x1).
Otherwise i didnot get you right. But what do you exactly mean for the bad engliSH man like me?
Thank you so much again
Nathnael
Chris Harris
Ranch Hand

Joined: Sep 21, 2003
Posts: 231
Hi,
Try the following code change:

Let me know, if that does not work.
If it still does not work and as you are just writting a small test app try:


Chris.
[ March 16, 2004: Message edited by: Chris Harris ]
Nathnael Haile-Mickael
Greenhorn

Joined: Mar 15, 2004
Posts: 15
Hi Chris,
I tried the code changes. the risult is negative:

for the (".//db-2x1", r") version the result is: system cannot find the file.
the 2. one has this result:...FNFE: D\:J2sdk1.4\Main.jar\db-2x1_db system cannot find the requested path.

sorry for bothering, it is very nice of you to help me.
Nathnael
Anna Hays
Ranch Hand

Joined: Nov 09, 2003
Posts: 131
Is '\db-2x1_db' a directory? If so, try 'db-2x1_db/db-2x1'
The root dir points to where your suncertify/ directory is by default. So just navigate from there. See if that work?
Chris Harris
Ranch Hand

Joined: Sep 21, 2003
Posts: 231
As Anna said when you do ".//file" means that the file is within you currently working directory. Therefore if you have placed the database within a sub-directory of you working directory you will need to include the sub-directory within your path. e.g ".//db-2x1_db//db-2x1"
Let us know if you are still having problems.
Chris.
Nathnael Haile-Mickael
Greenhorn

Joined: Mar 15, 2004
Posts: 15
Hi Anna, Hi Chris,
Sorry but nothing works upto now.
Yes Anna db-2x1_db\ is a subdirectory of my Main.jar\ directory. the db file called db-2x1 is to be found in both of these directories.
Please have a look one more time and see what results were followed.

i just modified the
1. new RandomAccessFile("D://J2sdk1.4/Main.jar", "r");
2. new RandomAccessFile("D://J2sdk1.4/Main.jar/db-2x1_db", "r");
---------------------------------------------------------------------
Result message is: D:\J2sdk1.4\Main.jar(Zugriff verweigert)-access denied.
3. and for all othe changes in the code like:
new RandomAccessFile("db-2x1", "r");
new RandomAccessFile("db-2x1_db/db-2x1", "r");
new RandomAccessFile(".//db-2x1", "r");
new RandomAccessFile("db-2x1_db", "r");
the result is: System cannot find this file.


i know it is terrible and thank you very much for your patient.
Nathnael.
George Marinkovich
Ranch Hand

Joined: Apr 15, 2003
Posts: 619
Hi Nathnael,
The database file should not be in a jar file.
Here's my suggestion. Copy the db-2x1 file to the same directory as the Main.jar file. That is, copy db-2x1 to the D:\J2sdk1.4 directory. Then try:

Then the database file is physically here: D:\J2sdk1.4\db-2x1
And you are refering to it by an absolute path as: "D:\\J2sdk1.4\\db-2x1"
(BTW, the double back slashes are necessary because a single back slash is an escape character for a string.)
So there should be no trouble finding it.
Let me know if this doesn't work.


Regards, George
SCJP, SCJD, SCWCD, SCBCD
Vishwa Kumba
Ranch Hand

Joined: Aug 27, 2003
Posts: 1066
Nathnael,
Can you give this a try.
I have changed your code slightly to use my database and also added raf.close() stmt.

1. I renamed your class from FileReader to DBTest. There is a conflicting JDK class with the same, java.io.FileReader. So FileReader is not a good idea for your test program.
2. My database filename has the suffix .db. (db-2x2.db). Does your database also have a similar suffix?
3. My working directory contains the following files and directories.

+ indicates it is a directory.
From the working directory: I run the cmd to generate the runme.jar file.
jar -cvfm runme.jar Manifest.mf -C classes .
From the working directory: To run the program:
java -jar runme.jar

Note that I am running the program from the working directory where runme.jar file and the database file db-2x2.db are both present.
It is the current directory so runme.jar will definitely find the database file.
Nathnael Haile-Mickael
Greenhorn

Joined: Mar 15, 2004
Posts: 15
Hello Everybody,
I am very glad to let you know that every thing is working. Thankx a lot for your Help, i am very gratefull.
The problem was that i was wrongly writing the db file name in the code without ".db" that means instead of "db-2x1" i was expected to write
"db-2x1.db"...
Sorry so much for bothering you with this nonsense but at least i lerned something.
I have a starter question but i open a new topic post.
MyBestRegards!
Nathnael
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NX: db-2x1?