Win a copy of Rust Web Development this week in the Other Languages forum!

Kathy Rogers

Ranch Hand
+ Follow
since Aug 04, 2000
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Kathy Rogers

Hi everyone,

In a bid to provide to the non-technical staff that I work with, that I do have functioning legs under my desk and that I'm sometimes to be found outdoors despite my nocturnal programming habits, I'm taking part in the University of Sheffield's Big Walk this September to raise money for medical research into lung disorders. We're walking 286 miles over 15 days from the Scottish borders back to Sheffield. And I'd like to ask for your help. But don't worry - I'm not asking for money! We've entered the Mountain Warehouse Charity Challenge in a bid to win £10,000 for our charity. So please, please, please could you vote for me (you need to provide a valid email address and then click the emailed verification link).

http://www.mountainwarehouse.com/charity/entries/the-big-walk-2015-e2497.aspx

There's lots of great causes on there - but don't worry. You can vote for more than one of us if you want, as long as you only vote once for each entry. And please re-share / retweet / ask your friends and colleagues to vote.

You can find out more about the Big Walk at http://www.sheffield.ac.uk/alumni/donate/specialfunds/the_big_walk or read my blog about our training / the walk at https://walkthebigwalk.wordpress.com/

Thank you so much!

Kathy
6 years ago
Hi,

I have a Netbeans project that contains much shared code and many libraries - database handling stuff, that sort of thing, which is common to all my projects.

In Netbeans 5.0, I created a "shared" library that referenced the build/web/WEB-INF/classes directory of my shared project and the jar files within the lib directory of the shared project. I would add this library to other projects as necessary. On building these other projects, Netbeans copied class files to the build/web/WEB-INF/classes subdirectories of the project being built and the jar files to the build/web/WEB-INF/lib directory. Essentially the code and lib files were integrated into the structure of the new project.

I have tried and failed to replicate this behaviour in Netbeans 6.7.1. I have tried creating a library - if I include the build/web/WEB-INF/classes directory from my shared project, when the new project is built, the build/web/WEB-INF/classes directory is copied to the build/web/WEB-INF/lib directory - not the desired behaviour. I could add lib/build/web/WEB-INF/classes to my classpath but I'm not happy about the idea of class files in my lib directory. I can make it work by adding a project, rather than a library - shared.jar is copied into WEB-INF/lib. I can also get it to work if I create a (local?) library containing shared.jar. However, what I ideally want is the package directory and class files of the shared project integrated into the package directory structure of the new project.

Any suggestions on how to achieve this very gratefully received.

Thanks,

Kathy
Hi Jeanne,

Thanks for the suggestion. I've tried getString but the autoconversion still happens - I suspect getString effectively calls a toString on a java.sql.Date object, rather than getting a String from the database.

I think you've identified the core of the problem when you point out I'm using database specific functionality, although within the context of this quite limited project, that seems fairly safe. The payoff for us of using the date field is that we can use the build-in SQL date functionality (to select within date ranges, for example).

The only solution I can see at the moment to the problem of selecting the date is to change my SQL so that I select the date as a String. What I'd really like is a way of specifying what object the JDBC uses to represent the Date field so that I could use a customised date class which allows these types of dates. Anyone know a way to do this?

Thanks again for your help,

Kathy
Hi,

I'm inserting and selecting dates into a MySQL database from jsp pages. However, some of the dates are uncertain - I don't know the month or day - so, for example I would like to insert the date as 2001-00-00 when I know the appropriate date is in 2001 but I don't know the month or day. MySQL recognises this as a valid date format for a DATE field and I can insert / select dates like this directly into MySQL. However, as soon as I start to insert these dates from a jsp page, the date is changed to an actual date (so 2001-00-00 gets inserted as 2000-11-30) and even if I directly correct the data in the database, when I select the date again from a jsp page, it is incorrect (again 2000-11-30) even though it is correct in the database.
I'm guessing that this a problem to do with automatic type conversion within JDBC and java.sql.Date not allowing 00 as a month / date value. Any suggestions as to a workaround / solution for both inserting and selecting these types of dates would be gratefully received.

Thanks in advance,
Kathy
As Dan says, I think simplicity is a big factor. Having occasionally worked with large XML documents, that we parsed ourselves, treating them as a String - for example, when we just wanted to find the content of the first element after a certain tag - you didn't necessarily keep track of all the characters - you just looked for a < to delimit that next element. So even though, looking at the XML, it's easy to see that < is within quotes and therefore unambigious, I suspect that many parsers will not necessarily take account of those quotes when dealing with the < character. Some people prefer to use an escape character for > as well, although there's no reason to do so, apart from consistency. It may seem very bad practice to just look for the < character to find a new tag but sometimes we found it necessary for performance reasons or to identify specific information before we parsed the XML properly, such as the company or type of XML document we were dealing with.
Hope this helps,
Kathy
Hi Ellen,
I've found it much easier to find "Patterns into code" books with C++ or even Smalltalk examples rather than Java, although I haven't looked for a while. However, one book that I would recommend checking out is Bruce Eckel's Thinking in Patterns. It's a work in progress and I haven't looked at it for a while but Eckel's is very readable and had plenty of accompanying code and best of all, it can be downloaded free. You can download it from here:-
Mindview's Thinking in Patterns site
or doing a search will produce lots of mirror sites. Bruce Eckel has written several books which are available to be downloaded for free and I found Thinking in Java really useful when I was learning basic java / preparing for programmer's certification and Thinking in Patterns useful when I started trying to code patterns in Java.
Hope this helps and good luck with your courses,
Kathy
19 years ago
Hi,
If you're beginning to get to grips with I/O, you're halfway there. I think the way to tackle this problem is to break it into much smaller problems.
1) Create a program that will read a text file in - hardcode the name of the text file.
2) Add to the program so that it will write exactly the same file out to a new file - hardcode the name of that new file too.
3) Now put in the funcionality to convert the first file into upper case after / as it is read in, so that the file written out is in upper case.
4) Decide how the user is going to specify the file name and add that code to your program - be it via command-line arguements, a text prompt, or a GUI file browser.
5) Tidy everything up - think about issues such as what happens if the output file already exists - do you have to deal with this or not?
So in the first attempt, I would ignore the issue of converting the text. One of the beauties of the OO approach should be that you can tackle a big problem in small chunks.
Sun's java tutorial on I/O has code examples on just about everything you need to do for I/O - so check that out at:-
Java IO tutorial
When thinking about converting the code, I'd consider using a Filter Stream or Reader or Writer - again the tutorial covers how to write your own filter stream.
If you want some information on converting Strings and Characters to upper-case, another Java tutorial might be useful.
Characters tutorial
Hope this helps - and gives you somewhere to start.
Kathy Rogers
19 years ago
B2B is just business-to-business - it's commonly used for relationships between suppliers and their business customers. In the company I worked for, we were dealing with large companies that bought a lot of hardware/software, which we sold, so we could spend some time setting up the links and procedures so that they could order from us. It's called B2B to distinguish it from B2C, or business-to-consumer, your typical private individual buys from Amazon scenario. There are issues which are different for B2B - for example, controlling who can place orders within the customer organisation, offering restricted catalogues or discounts or other special services and most importantly, tying in the supplier's system with existing purchasing systems/practices at the customer organisation.
Hope this makes more sense of my last message!
Kathy
Your problem here is not an input problem. It's to do with your while clause.
Think about it like this.
If I enter 1, then choice does not equal 2 and choice does not equal 3 but it does equal 1.
So when it gets to the while clause, you get
false OR true OR true
The while clause tests the condition and finds that it's true because at least one of the sub-conditions are true - so it does the do-while loop again . . . and again . . . and again.
You only want to perform the do-while loop again only if all the conditions are true - if choice does not equal 1 AND choice does not equal 2 AND choice does not equal 3 - so try replacing those ||s with &&s or checking if choice is less than 1 or greater than 3.
Btw, in order to pick up the user input using readLine(), you have to press return after you've entered your number.
Hope this helps,
Kathy
19 years ago
Hi,
Here's an example of how a client/customer might be responsible for creating/altering XML and hence produce XML that needs validating.
The only time I've used XML in a commercial environment is on a B2B team. Customers would send us orders in XML, we'd send shipping notices, and they'd be all sorts of XML notifications that these XML documents had been received/notices that the order couldn't be filled/ billing and payment information. True, some of these orders were placed by filling in a web form which we controlled. But for most of the customers or clients, they were responsible for creating the XML and could do it in a variety of ways - using customisable B2B products, programming their own solutions, using portals such as Ariba. Basically, we didn't care how they created the XML but we needed a way of checking that what they created was valid. We used DTDs, largely because our B2B product used DTDs, but also because it was quicker, as William said. We used validation largely when setting up sizeable customers - to work with them to get the XML into a format acceptable to us both - and turned it off during production, unless problems arose.
Hope this helps to explain how it's possible for clients to produce unacceptable XML.
Kathy
Hi Cornel,
Rene's right - a no-args constructor in Father would allow your code to compile.
Here's where the problem lies. Every time you write a class, if you don't write a constructor, Java inserts a default constructor (no args). However, if you explicitly write constructors, what you write is what you get.
Also in each constructor, there's a call to the constructor in the class above. Again, either you can write this or Java will automatically insert it for you. If you put the call in, it has to be the first thing in your constructor. If you don't put in this call, Java will insert a call to the no-args constructor of the parent class - if there isn't a no-args constructor, you're in trouble.
So the problem with your code is that Mother extends Father and the default constructor in Mother attempts to call the no args constructor in Father - and there isn't one. So you've got two possible solutions. You can either add a constructor to Mother, which explicitly calls the available constructor in Father:-

Or you can add another, no args, constructor to Father:-

Hope this helps,
Kathy
[ July 18, 2002: Message edited by: Kathy Rogers ]
19 years ago
Somewhere within your code, you're making a call to an instance method of a class - but you're doing that from within a static method so you're not calling that method on a specific instance. For example, you might be doing something like this:-

whereas what your main method needs to look like it this:-

or alternatively, it might be appropriate to make the printMessage method static.
Hope this helps,
Kathy
[ June 26, 2002: Message edited by: Kathy Rogers ]
19 years ago
But what happens if that equality condition isn't met?
Taariq's right about the problem being with the for loop missing that condition - it's just the condition you need is slightly different.
What your for loop does is take the first member of the s array and then checks it against each member of the testCase array. Say, for example, the choice array has three members - first time through the loop, it checks if s[0] equals testCase[0], second time through if s[0] equals testCase[1] and third time if s[0] equals testCase[2]. That works just fine if s[0] equals testCase[0], testCase[1], or testCase[2] - it finds a match and it breaks out of the loop. However, if it doesn't find a match, the for loop continues to check to see if s[0] equals testCase[3] and there is none in this case - that's when you get your exception. Doesn't matter what the actual length of testCase is in practice - it can always happen that the for loop will reach the end of it and then try to access another array member which doesn't exist. So you need your for loop to look like this:-

Even if you're certain that something within the body of your for loop will cause it to terminate, it's always a good idea to put in that condition just in case.
Hope this solves the problem.
Kathy
[ June 24, 2002: Message edited by: Kathy Rogers ]
19 years ago
Try using the setSelectionInterval(index,index) method instead of addSelectionInterval.
Hope this solves the problem,
Kathy
19 years ago
Try using a BufferedWriter to wrap the FileWriter (by using a constructor like this:- new BufferedWriter(new FileWriter(outFile)) ). BufferedWriter has a newLine method() which you can use instead of \n.
Hope this helps,
Kathy
19 years ago