Win a copy of Head First Android this week in the Android forum!

Simon Birch

Greenhorn
+ Follow
since Dec 26, 2003
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 Simon Birch

I'm trying to merge data from a SQL server database with data from a DB2 database, and I've hit a snag. The DB2 database sits on a mainframe and sorts data in an EBCDIC based order (i.e. letters before numbers). The SQL database, and Java .compareTo() place numbers before letters.

I'd like to change the collation used by DB2 and I'm told that it can be done by providing a parameter on binding my SQL. I'm having some problems find out how to do this in Java though. Any help or pointers would be greatly appreciated.

We are using DB2 version 7, and SQL Server 2000.

A snippet of my current Java code:
I occasionally find myself wanting to re-read one of the replies to a question I asked some time ago.

Unfortunately, the only way I've found of doing this is to first locate any post I've made on the forums so that I can access the 'Profile' page and from there the 'View recent Posts' link.

As I'm not a frequent poster of questions, I've first got to find a post I've made... (spot the infinate loop).

Have I missed a link somewhere that would enable me to see recent posts without having to first find another post that I've made?
16 years ago
I'm sure this must be something daft on my part.

When the expected output is 00:03:16.492, I'm getting 01:03:16.492
When the expected output is 01:19:56.492, I'm getting 02:19:56.492
If I try setting the time to 0 I get 01:00:00.000

Here is the code;
16 years ago
Hi Andrew, welcome to JavaRanch.

Java is case sensitive. All you need to do is make the file name 'MyFirstApp.java' rather than 'myfirstapp.java'.

Incidentally, this is also the reason you get the Exception statement when you remove 'public' from the program. You are trying to use a class called 'myfirstapp', but its actual name is 'MyFirstApp'.

Hope that helps.
16 years ago
Yes - I tried that sort of thing.

Again - the only reason I can think of to do this would be to limit the scope and life of a variable. I guess this is useful to clarify the intent of code, but I thought that methods ought to be kept as short as possible anyway. Adding an arbitrary block of code still seems redundant.
16 years ago
I tried the following - just out of curiosity;


I was slightly surprised when it compiled and produced


The only use I could think of was limiting variable scope - but that seems redundant given the limiting provided within 'normal' code blocks (if, for, etc)

Is this just 'the way it works', or is there a practical use for declaring arbitrary code blocks?
16 years ago
Hi,

The most obvious error in the code is the top line which should read


With this change the code compiles and runs fine for me.
I tried this, using the following properties


Initally, I omitted the "\n" at the end of the Class-Path and it didn't appear in the manifest.mf file, although the Manifest-Version line did appear. Using the code above gave me a manifest.mf file with both lines in it.

Does this give you any help? Could we see your code in full?
16 years ago
Glad you got the code going Arto, but I'd really think about either not using the Thread or putting all the file handling into the Thread code.
16 years ago
I've done some experimenting. The problem you are having is caused by seperating the file writing and closing into different threads.

After the t.start(), the JVM will be executing two threads - one is your code in the run method, the other is the code folloing on from where you called start(). These two threads of execution have no guarantees about the order in which they will be processed, or about when one thread might be stopped and the other started.

I guess what you are experiencing is the JVM completing the raf.close() before it gets to the raf.write().

How to solve this depends on what you are trying to achieve. Do you actually NEED to use a sperate thread?

If not, the following might be a better approach (I'm using windows, so I've changed the file name for ease):
16 years ago
In that case, I would look at the object referred to by 'f'. The file name may be mangled in some way. Can you access the file through f? What do you get if you try


That might help zero in on the problem.
16 years ago
I think what is happening here is that you are creating a Thread object with your own run method. But you never call any methods on the Thread object, so the code you have in the run method is never executed.

You need to call the start() method on Thread in order to execute the code in the run() method in a seperate thread.
16 years ago
Thanks for your reply Marc. Unfortunately, when I tried that, I got an almost identical error to the one I posted previously. Here it is (with line breaks this time )


Does this point to me doing something daft that is preventing the <%=indexNumber%> from working?
16 years ago
I'm trying to produce a list of items in a page by iterating over a List of those items. As long as I don't try to use a radio button, the list works fine. Unfortunately, the radio button is somewhat essential.

Here is a snippet of the code from the Action (by the way reportName is a misnomer at the moment - it's supposed to be the report index number)


The page contains the following:


With this code, I get a JSP compilation error appearing in the web page.



I've tried using an ordinary <input> tag with the same bit of script used in the html:radio tag above - and it lists fine, but doesn't initialise the radio button.

I must be doing something daft - but I've no idea what it is. Can anyone point me in the right direction (or even solve the problem!).

Thanks in advance.

[ Jess added new lines in the error message so the screen doesn't get stretched too far ]

[ January 24, 2005: Message edited by: Jessica Sant ]
[ January 24, 2005: Message edited by: Simon Birch ]
16 years ago
There are several tasts you need to perform to write the Phone class. In no particular order
  • Convert a letter to a number
  • Identify each letter of the entered word
  • Add each number to the actual phone number
  • Format the phone number

  • Which part of the program is causing you difficulty? Does breaking it down (e.g. like the above) help?

    You could just try breaking down each of the above until you get to writing code.
    17 years ago