Hans ter Wal

Greenhorn
+ Follow
since Oct 01, 2003
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Hans ter Wal

Thanks Jason! I knew I was missing something, the columnModel :-)
Hans
Hi yall,
I'm working on the front-end of my URLyBird assignment, for testing purposes I've build a "getAllRecords" method. When I start my client, it gets all the records from the datafile and displays them in a jtable. In my GUI I've got a seperated panel that shows the record details for a record, a user selects from the jtable. In the panel I've got a editable text field that lets the user enter a customer number. When the user presses the book button I want my application to book that record, but how do I know which record to update?
My solution so far is to add the position in the String[][] that the getRecords() method returns and fill my table with. But I don't want to display the record number in my GUI. How can I construct my jtable with data but only show the relevant columns?
This is my contructor for my ClientTableModel that extends the AbstactTableModel

Any ideas would be appriciated,
Best regards,
Hans

Originally posted by Peter Yunguang Qiu:
Thanks Hans.
In my DB access file, I just used RandamAccessFile. I think it is easier than use many stream classes. What do you think of it?


Hi Peter,
Like you I've just started with the assignment (urlybird 1.3.2), what I've done I first brewed some coffee and put in some long nights just to go through this forum and look at common problems that everyone has/is faced/facing during completion of the assigment.
For example the usage of a randomaccess file, is one of the or more likely the most used solution for db access. Some people cache it some don't (including me). Why? Because I like to keep things simple, I might change my mind in the future but for now no caching.

Hi, Hans:
Using JUnit, it seems need more work than directly test. I just print out the record that been readed, and see by my eyes. It seems simpler and need less work.
Peter


This is my first JUnit project and with the testing of the data section i've reaked the benefits (made some mistakes that where easy to mis with simple print statements). If you like to put in print statements thats fine, but it clutters you're code, junit provides a graphic framework that shows you if you're tests succeed or fail. (Green is good and red is Evil) and can be completely seperated with the you're going to submit.
I use Eclipse as my IDE and it comes with JUnit, development could not be easier (except if someone else did it for you ;-) ).
Try www.junit.org there are some tutorials there and www.eclipse.org for the IDE.

Well it's back to work for me

Regards,

Hans

Originally posted by Derek Canaan:
Hi Hans,
Thanks for sharing. Could you also share how you use junit to test concurrent read-read, and read-write?
Thanks in advance,
Derek


Hi Derek,
I'm sorry to say that i'm not that far along in my assigment to be of any assistance, if got some ideas as how to but I not sure myself and I don't want to send you in the wrong direction.
Look at Junit for some more info
http://www.junit.org

Regards

Hans
Hi Peter,

JUnit is a great tool!
If recently started with it so if I'm saying something wrong please correct me anyone.
How I implemented in my project is to create to src's directorie ie.
project-->code-->suncertify-->db
project-->Test-->suncertify-->db
In creating a new source directory you seperate testing code with the code you're going to submit to sun. The package names are the same so that you can access classes as if they where in the same directory.
Now on for the good stuff.
There are different ways to use JUnit, the following is one of the options JUnit offers.
In the testing package "project-->Test-->suncertify-->db" you create a class that that extends junit.framework.TestCase.
All the test cases you want to create must have a public modifier and return void and last but not least should start with 'test'.
public void testReadFirstRecord() {}
So how do you test if something is amiss. Every test case has an expected result for example, testReadFirstRecord() should get the first db record.
The assertEquals(String expect, String result) method checks to see is the data you requested is the same as you expected. The method returns a boolean that the junit framework uses to determine if the testcase succeeded or not.
the setUp() and tearDown() method are used before and after every single test case method in the testCase class. For testing the data class it's very important that you use an 'fresh' db file. If you don't one of you're methods can corrupt the file you working on and well you get the idea;-)
Here some of the code I use

Thx Terry and Andrew,
I'll go with the suncertify package then :-)
Thanks for the help on the singleton thing 'multiton' gives me a few more threads to read through, going to go through them first.

Hoi Hans


Do you know more dutch Andrew? ;-)
Regards,
Hans
Hi everyone,
I've started my assigment with trying to get the read/search/create to work. I did this by putting a file access in the data class. This works fine, but makes my class very unclear. Seeing as almost everybody is using a datahelper/dataschema helper class to do all file access, I'm wanting to do same.
Somethings are unclear to me though:
1. If I give my clients a data class each the dataHelper class is a singleton?
2. My assigment specifies that the data.java and all exceptions thrown from it should be put in the suncertify.db package. But can I or must I put my dataHelper in the same package or must I put it in one of my own packages
Regards,
Hans
Hi y'all,
That did the trick, I also meant I was using a RandomAccessFile.
I thought it worked the same but afterreading the javadoc on it:


"rw" Open for reading and writing. If the file does not already exist then an attempt will be made to create it.


and I had:

Thanks for clearing things up guys!
Hans
Hi Andrew,
Thanx welcome and the reply.
I went for option 2
Regards,
Hans
Hi y'all,
Just my $0.02 , i've had the exact same problem here. Spec's 1.4.2 running under winxp.
Believe when i say, i get new files in my explorer, I 100% sure because i specified the file path wrong, after looking it created a new file.
Hans
My first time in this forum howdy all!!
I've just started with my 1.2.3 version of the URLyBIRD assignment. I've started reading the forum for hints tips an ideas. But there are so many things to concider, I'm almost afraid of starting of the wrong way, but today I finally opened eclipse and started with the data access layer.
I'm just putting the data access in one class right now, till it works and refactoring it as i go along.
What I was thinking was that the "server"controller class, creates one instance of the Data class. The constructor of the Data-Class opens a RA file object for file access. (and somewhere the server class calls a close for the RA file object)
What i'm still not certain of is how to access the data section of the data file.
First of you have to get to the data section of the db.file
What would be the correct way?
1.

or...
2.


I've someone could give me a push in the right direction,

Regards,
Hans
[Andrew: broke up long lines so that this displays without requiring horizontal scrolling]
[ November 13, 2003: Message edited by: Andrew Monkhouse ]
[Update]
Seemed that the data type of one of fields was CHAR and wasn't all the way up with appended with spaces, somehow a statement does this automatically.
Hans

Hi everyone,
I'm having some problems with one of my preparedStatements, which used to work fine some time ago, but now seem to be giving me a no result. The strange thing is that when I use a normal statement I get a result back, or if I use a another preparedStatement it works fine. The database is Oracle and the appserver is websphere 5, I'm not getting any exceptions just an empty resultset. I've there is anyone who can give me some insight I would be much appreciated!!
Regards,
Hans ter Wal
PS The are 10 spaces included in the T$ITEM But the browser only shows one
======= Statement 1 - the problem giving one =============
....
ps = c.prepareStatement(
"SELECT T$AMNT, T$PERC FROM TTDSLS911100 WHERE T$BDNO = ? AND ( T$ITEM = ? OR T$CPRG = ? ) AND T$STDT <= sysdate AND sysdate <= T$EDDT",
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
ps.setString(1, "testbid");
ps.setString(2, " C1806A"); //10 spaces included in the T$ITEM
ps.setString(3, "237113");
rs = ps.executeQuery();
if (rs.first()) {
out.println("yeaha<br>");
} else {
out.println("grrrrrE<br>");
}
....
Result: grrrrrrE
======= Statement 2 - No problem statemen =============
...
stmt = c.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
rs = stmt.executeQuery("SELECT T$AMNT, T$PERC FROM TTDSLS911100 WHERE T$BDNO = "testbid" AND ( T$ITEM = " C1806A" OR T$CPRG = "237113" ) AND T$STDT <= sysdate AND sysdate <= T$EDDT");//10 spaces included in the T$ITEM

if (rs.first()) {
out.println("yeaha<br>");
} else {
out.println("grrrrrE<br>");
}
...
Result: Yeaha
=================== Statement 3 no prob statement ========
...
ps = c.prepareStatement(
"SELECT TTIITM001100.T$VOOR FROM TTIITM001100 WHERE TTIITM001100.T$ITEM = ?",
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
ps.setString(1, " C1806A");//10 spaces included in the T$ITEM
rs = ps.executeQuery();
if (rs.first()) {
out.println("yeaha<br>");
} else {
out.println("grrrrrE<br>");
}
...
Result: Yeaha
[ October 23, 2003: Message edited by: Hans ter Wal ]
[ October 24, 2003: Message edited by: Hans ter Wal ]