comp.lang.java.programmer
http://groups-beta.google.com/group/comp.lang.java.programmer
[EMAIL PROTECTED]

Today's topics:

* Code evaluation - 2 messages, 2 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e324af9474331ba5
* Difference in int cast to char between Windows and redhat linux 9 under JDK 
1.4.2_06 - 3 messages, 3 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1d1f4b314e97f2cd
* Using hobby source code in your job ? - 2 messages, 2 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a60dfe865a7807c4
* NoSuchMethodException when reflecting ServletContext as a parameter - 1 
messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a447e67bb400d60c
* Can Java Programmer Learn C++ Quickly? - 2 messages, 2 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7c7a28aa864e41ec
* cannot resolve symbol? - 2 messages, 2 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/994fbf9c94a91673
* Eclipse programming help need - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f6b82d6d4f401650
* xml to xml mapping table conventions - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f59b8afc67f2eb5c
* MIDP MIDlet: which characters are supported in the phone font? - 2 messages, 
2 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/73bdfdf7f36c6ea0
* JOptionPane - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6f5e847fca146a36
* Another simple problem - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f3052e16ead05747
* How to tell which interface is implemented - 2 messages, 2 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4033d866640efd11
* jdbc connect to mysql database - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/562500384f66e601
* Where do they go? - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/13296f4262fb9757
* Advice on persistent storage in Java? - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e1b92789433bcb07
* Problem wtih Java ThreadGroup.activeCount method - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/80c6f5e77859ec02
* JAVA/ ORACLE/ CONTRACT/ FL - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c2089808879d1377

==============================================================================
TOPIC: Code evaluation
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e324af9474331ba5
==============================================================================

== 1 of 2 ==
Date: Sat, Dec 11 2004 12:35 am
From: Arnaud Casteigts <[EMAIL PROTECTED]> 

Hi,
Is there a way in Java to evaluate (execute) a code dynamically 
generated ? (as PHP function eval() for example)

thanks by advance !



== 2 of 2 ==
Date: Sat, Dec 11 2004 12:38 am
From: Alex Kizub  

> Is there a way in Java to evaluate (execute) a code dynamically
> generated ? (as PHP function eval() for example)

Even Java is interpreter it still require complier, then byte code, then
execution.
So, answer is no.
Of course you can run javac in separate thread or use your own compiler.

But if you can do this then c.l.j.p. is not for you. :)
Alex Kizub.





==============================================================================
TOPIC: Difference in int cast to char between Windows and redhat linux 9 under 
JDK 1.4.2_06
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1d1f4b314e97f2cd
==============================================================================

== 1 of 3 ==
Date: Fri, Dec 10 2004 6:18 pm
From: "Private"  

Difference in int cast to char between Windows and redhat linux 9 under JDK
1.4.2_06

With regards to the following; how can I control the charset used for the
cast ? The desired outcome would be for 0x80 to cast to '\u0080'. At
the least I need to be able to run consistently across the two platforms.

Thanks to all for any help on this.

<java code CharTester fragment>

  FileInputStream fis=new FileInputStream(args[0]);

  for (int i=fis.read();i>-1;i=fis.read())
   System.out.print((char)i);

  System.out.flush();
  fis.close();

</fragment>

<test run under linux>

# hexdump -C < print.doc
00000000  7e 7f 80 81 fc fd ff                              |~......|
00000007

# java com.asl.hacks.CharTester print.doc
# java com.asl.hacks.CharTester print.doc | hexdump -C
00000000  7e 7f c2 80 c2 81 c3 bc  c3 bd c3 bf              |~...........|
0000000c

</test>

under windows the same command produces

7e 7f 3f 3f fc fd ff





== 2 of 3 ==
Date: Sat, Dec 11 2004 12:39 am
From: Alex Kizub  

> under windows the same command produces
>
> 7e 7f 3f 3f fc fd ff

You use none ASCII characters. Read more about InputStream and Readers and what
is the difference betwen them.
Also check what is the locale on your Windows and Linux systems. I bet they are
different.

Alex Kizub.




== 3 of 3 ==
Date: Sat, Dec 11 2004 2:30 am
From: Michael Borgwardt 
 

Private wrote:
> Difference in int cast to char between Windows and redhat linux 9 under JDK
> 1.4.2_06

No.

> With regards to the following; how can I control the charset used for the
> cast ?

There is no charset involved in such a cast, both are integer types.

> The desired outcome would be for 0x80 to cast to '\u0080'.

And that is what will happen. Always.

> <java code CharTester fragment>
> 
>   FileInputStream fis=new FileInputStream(args[0]);
> 
>   for (int i=fis.read();i>-1;i=fis.read())
>    System.out.print((char)i);

Ah, well this is a different thing. You are reading the byte values and
interpreting them as unicode code points. That's equivalent to using
the ISO-8859-1 charset.

But the platform dependence is not in the casting from int, it's in the
call of print(), which uses the platform default encoding to convert the
character back to bytes, which then appear on the program's standard
output.

What is the program supposed to do, anyway?




==============================================================================
TOPIC: Using hobby source code in your job ?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a60dfe865a7807c4
==============================================================================

== 1 of 2 ==
Date: Sat, Dec 11 2004 12:36 am
From: Bob Hairgrove  

On 10 Dec 2004 13:40:05 -0800, "JeffS" <[EMAIL PROTECTED]> wrote:

>It seems to me that most programmers, especially contractors who go
>from job to job, reuse code they either did as a hobby or wrote for
>some other employer.  It's just that they don't copy and paste it line
>by line, they modify it for the most current use, and obfuscate it as
>well.

[big snip]

IANAL, but some things simply aren't patentable or subject to
copyright. Who has the patent on white flour? Salt? Butter? Put them
together in the right proportions, throw in a little yeast and some
"secret ingredient", then maybe you come up with a recipe for bread
which *is* patentable.

Everybody uses and reuses things like the quick sort algorithm. If you
write your own implementation of it, nobody can enforce ownership of
the IP because it's merely a wheel, and one that has been used and
reused many times over again. Nobody ever invented the wheel, it's
just always been there ... the same thing probably applies to things
like smart pointers, except that no one has come up with one single
version that pleases all the people all the time.

My point is that to enforce patents or copyright, it is necessary to
prove that the design of a product, and not necessarily the
ingredients which go into the making, are original and innovative in
nature. An entire operating system can be patentable and still be
written with code which isn't.

--
Bob Hairgrove
[EMAIL PROTECTED]



== 2 of 2 ==
Date: Sat, Dec 11 2004 12:23 am
From: Keith Thompson  

Bob Hairgrove <[EMAIL PROTECTED]> writes:
> On 10 Dec 2004 13:40:05 -0800, "JeffS" <[EMAIL PROTECTED]> wrote:
>
[snip]
>
> [big snip]
>
> IANAL
[bigger snip]

If you're not a laywer, why are you giving legal advice?

In particular, why are you giving legal advice in multiple newsgroups,
when it's off-topic in *all* of them?

-- 
Keith Thompson (The_Other_Keith) [EMAIL PROTECTED]  <http://www.ghoti.net/~kst>
San Diego Supercomputer Center             <*>  <http://users.sdsc.edu/~kst>
We must do something.  This is something.  Therefore, we must do this.




==============================================================================
TOPIC: NoSuchMethodException when reflecting ServletContext as a parameter
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a447e67bb400d60c
==============================================================================

== 1 of 1 ==
Date: Fri, Dec 10 2004 6:43 pm
From: "John C. Bollinger"  

natG wrote:

> John C. Bollinger wrote:
>> Similar problems can apply to primitive arguments, too, because they 
>> can be promoted according to method invocation conversion rules.  (JLS 
>> 2ed, section 5.3)
> 
> 
> I would never dream that some sort of subclassing might be applied to 
> primitives, and I still don't really get it, but I'll google "JLS 2ed, 
> section 5.3", over the weekend to study this.

JLS = Java Language Specification.  The section number cited is correct 
for the 2nd edition of the spec (= 2ed).  Specifically, that section 
describes how actual arguments of narrower primitive types can be 
matched to methods with wider formal argument types.  For instance, you 
can pass a short to a method with formal parameter type int, long, or 
double (or float, if I recall correctly).

[...]

>> Because whatever the ServletContext implementation class happens to 
>> be, it is definitely *not* javax.servlet.ServletContext.
> 
> 
> True. I even tried casting the object parameter with (ServletContext), 
> to no avail.

Casting never changes the class of an object, which is what your Invoker 
relies on.  The sole effect of a typecast expression is to specify the 
formal type of the expression result (with associated runtime check). 
It is more relevant at compile-time than at runtime.

>>>         new Invoker("methodA", new Object[]{ctx,s1}); //this does NOT.
>>
>>
>> [does not work, that is.]
> 
> You're subtle unrelated correction of my //comment has taught me more, 
> much more, in general, and at an abstract level, than everything this 
> thread topic is all about. Incredible. When I saw this correction, I 
> realized I had quick, clear thinking professor mentoring me. I will post 
>  both lines below so that others understand.

Don't butter me up too much, I might get delusions of grandeur.  I am 
pleased that you find my comments illuminating, though.

> "new Invoker("methodA", new Object[]{s0,s1});  //this works ok."
> "new Invoker("methodA", new Object[]{ctx,s1}); //this does NOT."
> 
> (Speaking at this level, can you please explain why you used [brackets] 
> for the correction? (Sorry, if I off on a tangent.) )

I would have inserted it into the comment itself, with brackets, but I 
wanted to avoid confusion about who wrote what.  Nothing deep there.  I 
snipped the first of those two lines because I had removed the 
corresponding method from the target class.

>> Do not be confused between the type of a reference variable and the 
>> class of the object to which the variable refers.  They do not need to 
>> be the same.  Even if the variable type is a final class type, the 
>> variable value can still be null (and that will cause your Invoker to 
>> throw a NullPointerException even though there may be a suitable 
>> method it could invoke).
> 
> 
> There are many api methods that a null parameter is used by design. Can 
> I then not call these reflectively? (Other than catching NPE.)

Sure you can, but not with your current Invoker implementation.  You 
would have to explicitly check each argument to see whether it was null 
before invoking getClass() on it.  You would have less information to 
use in determining the correct method to invoke when one or more 
arguments are null, and thus greater likelihood of ambiguity, but there 
is no inherent showstopper there.  The API docs for class Method 
describe how to pass a null argument to a reflectively invoked method.

I urge you to spend more time studying how to program generically and 
less time studying reflection.  There are techniques to minimize or even 
eliminate need for reflection, and these should be employed wherever 
possible.  You will have cleaner, more maintainable code.


John Bollinger
[EMAIL PROTECTED]




==============================================================================
TOPIC: Can Java Programmer Learn C++ Quickly?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7c7a28aa864e41ec
==============================================================================

== 1 of 2 ==
Date: Fri, Dec 10 2004 11:27 pm
From: Dimitri Maziuk  

Stephen Kellett sez:
... 
> As to your second point - why anyone would go back to C after the 
> usefulness and much improved type safety and expressiveness of C++ is 
> beyond me.

C standard library is guaranteed to be present on any unix machine,
C++ is not.

C has ABI, so the above library will probably work with your code.
No such luck with C++.

Whenever new C/C++ standard comes out, C++ one tends to break
existing code bad. C is an older and more stable language so
it doesn't break quite as easily.

If you're good at C improved type safety and expressiveness of
C++ are of questionable value to you.

etc.

Dima
-- 
Yes, Java is so bulletproofed that to a C programmer it feels like being in a
straightjacket, but it's a really comfy and warm straightjacket, and the world
would be a safer place if everyone was straightjacketed most of the time.
                                                      -- Mark 'Kamikaze' Hughes



== 2 of 2 ==
Date: Sat, Dec 11 2004 3:54 am
From: "Michiel Konstapel"  

>> Wait till you first bump into trying to make a virtual function call
>> from a constructor or destructor...
>
> That works in Java?

Sure. My question would be, why doesn't it in C++?
Michiel




==============================================================================
TOPIC: cannot resolve symbol?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/994fbf9c94a91673
==============================================================================

== 1 of 2 ==
Date: Fri, Dec 10 2004 3:55 pm
From: [EMAIL PROTECTED] (Ah Ming) 

Hi!

  I write a java code and compile with the following error.  What would happen?
Thanks for your help!  The coding is shown below the error message.

Ming

reverse.java:24: cannot resolve symbol
symbol  : method parseInt (java.lang.StringBuffer)
location: class java.lang.Integer
        num=Integer.parseInt(b);

1   import java.io.*;
2   import java.lang.*;
3   public class reverse
4   {
5      public static void main(String args[]) throws IOException
6      {
7         int num;
8         String str;
9         BufferedReader buf;
10        buf=new BufferedReader(new InputStreamReader(System.in));
11        System.out.print("Input an integer:");
12        str=buf.readLine(); 
13        num=Integer.parseInt(str); 
14        System.out.println("The integer is "+reverse(num));
15     }
16     public static int reverse(int input)
17     {
18         int num;
19         String a;
20          a = Integer.toString(input);
21          System.out.println("\nOriginal string: " + a);
22          StringBuffer b = new StringBuffer(a).reverse();
23          System.out.println("Reverse character string: " + b);
24          num=Integer.parseInt(b); 
25          return num;
26     }
27  }



== 2 of 2 ==
Date: Fri, Dec 10 2004 5:06 pm
From: Andy Hill  

[EMAIL PROTECTED] (Ah Ming) wrote:

>Hi!
>
>  I write a java code and compile with the following error.  What would happen?
>Thanks for your help!  The coding is shown below the error message.
>
>Ming
>
>reverse.java:24: cannot resolve symbol
>symbol  : method parseInt (java.lang.StringBuffer)
>location: class java.lang.Integer
>        num=Integer.parseInt(b);
>
Seems clear enough.   There is no Integer.parseInt() that takes a StringBuffer
argument.   Construct a String using the StringBuffer first, and pass the String
to parseInt.




==============================================================================
TOPIC: Eclipse programming help need
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f6b82d6d4f401650
==============================================================================

== 1 of 1 ==
Date: Fri, Dec 10 2004 3:14 pm
From: Allan Wax  

I'm new to Eclipse programming but have done a few things (but years of 
Java/Swing things).  I'm trying to find a listener for a View that is 
notified when the view is visible on the screen and also notified when 
it isn't.  I've tried ShellAdapter.shellActivated, componentAdapter and 
focusListener but none seem to do the right thing for what I want.  Is 
there some other listener or technique to get the job done?

Allan Wax




==============================================================================
TOPIC: xml to xml mapping table conventions
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f59b8afc67f2eb5c
==============================================================================

== 1 of 1 ==
Date: Fri, Dec 10 2004 4:06 pm
From: [EMAIL PROTECTED] 

I need to create a xml to xml mapping table. I need to layout how
elements are mapped from one schema to another schema. I want to know
if there are any standard conventions? For example, how to represent
multiple elements (1..*)?

Please advise. thanks!!





==============================================================================
TOPIC: MIDP MIDlet: which characters are supported in the phone font?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/73bdfdf7f36c6ea0
==============================================================================

== 1 of 2 ==
Date: Sat, Dec 11 2004 3:09 am
From: Michael Borgwardt 
 

Darryl L. Pierce wrote:
>>>> What *are* a "country's displayable characters"?
>>>
>>> Take, for example, the font used to display Korean characters.
>>
>> And do what with it?
> 
> It's an example of a displayable characters for a specific country's 
> language. Are you interested in information or argument?

No, I'm interested in giving a helpful answer to the specific question,
and I think your answer is more likely to confuse the original poster
than help him.

The key word you used was "font". The font is what determines which
characters can be displayed on a Java system. Not a "locale".

>>> Who said anything about the Locale class?
>>
>> What else did you mean when you said "It supports whatever locale(s)
>> are on the phone."?
> 
> Locale is not exclusive to the set of Java APIs. The word locale, as I 
> used it above, means "[a] geopolitical place or area, especially in the
> context of configuring an operating system or application
> program with its character sets, date and time formats,
> currency formats etc." (dictionary.com)

The Locale class is Java's implementation of that concept, and it has
nothing to do with "displayable characters". If you use the word to mean
something else on this NG, that's rather misleading.


> An example of a local supported by a phone would be those phones 
> manufactured in Korea which have only Korean characters displayed by the 
> font set on the phone.

I rather doubt any of them do not also display latin letters.

Locales are not the key to answering the original poster's question.
Fonts are. Of course, the fonts available on a device will contain
some or all of the characters commonly used on the locales it supports,
but that's not really relevant in regard to mathematical symbols,
because most of them are not part of any natural language.

In fact, I very much doubt any java-enabled mobile phone out there
supports a wide range of mathematical symbols out of the box, since
they have to make the most of their limited memory. There may be
some that allow updating / changing the fonts.









== 2 of 2 ==
Date: Fri, Dec 10 2004 10:03 pm
From: "Darryl L. Pierce"  

Michael Borgwardt wrote:
>>>>> What *are* a "country's displayable characters"?
>>>>
>>>> Take, for example, the font used to display Korean characters.
>>>
>>> And do what with it?
>>
>> It's an example of a displayable characters for a specific country's 
>> language. Are you interested in information or argument?
> 
> No, I'm interested in giving a helpful answer to the specific question,
> and I think your answer is more likely to confuse the original poster
> than help him.

Sorry, what exactly was confusing about what I replied with?

> The key word you used was "font". The font is what determines which
> characters can be displayed on a Java system. Not a "locale".

Sounds more like my answer confused *you*. The font used is determined 
by the locale where the phone is meant to be used. A locale is a 
location, and regarding a mobile it's a location where that phone is 
meant to be used. You won't find a phone with Big5 or Traditional 
Chinese being sold widely in the US because that would be the wrong 
locale for using such a device....

>>>> Who said anything about the Locale class?
>>>
>>> What else did you mean when you said "It supports whatever locale(s)
>>> are on the phone."?
>>
>> Locale is not exclusive to the set of Java APIs. The word locale, as I 
>> used it above, means "[a] geopolitical place or area, especially in the
>> context of configuring an operating system or application
>> program with its character sets, date and time formats,
>> currency formats etc." (dictionary.com)
> 
> The Locale class is Java's implementation of that concept, and it has
> nothing to do with "displayable characters". If you use the word to mean
> something else on this NG, that's rather misleading.

Then perhaps, in future, you should devote just a *wee* bit of time to 
the topic of the person's question. There is *no* Locale class in the 
MIDP. And, I said nothing *about* the Locale class. I said:

"It supports whatever locale(s) are on the phone. "

In response to the original poster's question:

"Which unicode characters does a phone support? Is this defined
somewhere? Does a phone support pi and math symbols and arrows?"

And the answer was *very* clear. Nothing about classes not available on 
mobile phones. I said that the characters displayed on the phone are 
going to be for what ever locale the phone was made to support.

>> An example of a local supported by a phone would be those phones 
>> manufactured in Korea which have only Korean characters displayed by 
>> the font set on the phone.
> 
> I rather doubt any of them do not also display latin letters.

Where did I say anything about Latin? Are you interested in an argument, 
then? You seem to want to argue over some slight only you perceive here...

> Locales are not the key to answering the original poster's question.
> Fonts are. Of course, the fonts available on a device will contain
> some or all of the characters commonly used on the locales it supports,

Oh, so now *you* are saying that the characters supported on the device 
are based on the locale? But, before you said "[t]he font is what 
determines which characters can be displayed on a Java system. Not a 
'locale'" when *I* said it depends on the locale. So, which is it?

> but that's not really relevant in regard to mathematical symbols,
> because most of them are not part of any natural language.

So?

> In fact, I very much doubt any java-enabled mobile phone out there
> supports a wide range of mathematical symbols out of the box, since
> they have to make the most of their limited memory. 

Then you *might* want to spend a bit of time looking into the subject 
matter before telling someone who's been in the Java mobile industry for 
over 5 years what's what. Sound reasonable?

> There may be
> some that allow updating / changing the fonts.

Again, so? Rather than itching for a Usenet fight, why not look into the 
subject matter or ask someone to clarify their posts rather than 
unnecessarily posturing yourself like you've done in this thread?

-- 
Darryl L. Pierce <[EMAIL PROTECTED]>
Visit my webpage: <http://mcpierce.multiply.com>
"By doubting we come to inquiry, through inquiry truth."
     - Peter Abelard




==============================================================================
TOPIC: JOptionPane
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6f5e847fca146a36
==============================================================================

== 1 of 1 ==
Date: Fri, Dec 10 2004 9:11 pm
From: "juicy"  

i put JOptionPane.toFront() or JOptionPane.showConfirmDialog.toFront()?

but still cannot...






==============================================================================
TOPIC: Another simple problem
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f3052e16ead05747
==============================================================================

== 1 of 1 ==
Date: Sat, Dec 11 2004 2:16 am
From: "George W. Cherry"  


"Joona I Palaste" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> [EMAIL PROTECTED] scribbled the following:
>> The constructor name has to be the same as the class name.
>
> Which is something that has lately struck me as needless. Why not have
> a special keyword for constructors? Such as "new"? For example:
>
> public class Foobar {
>  public new() {
>    /* ... */
>  }
>  public new(int foo, int bar) {
>    /* ... */
>  }
> }
>
> There is no loss of information, because every constructor in the same
> class must have the same name anyway.

Cool. Of course, the old verbose, less clear notation

public class Foobar {
    public Foobar () {
        /* ... */
    }

    public Foobar (int foo, int bar) {
       /* ... */
    }
 }

would still have to be legal. But who would use it
instead of your suggestion in new code.

George 






==============================================================================
TOPIC: How to tell which interface is implemented
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4033d866640efd11
==============================================================================

== 1 of 2 ==
Date: Fri, Dec 10 2004 6:34 pm
From: [EMAIL PROTECTED] 

Example,

If an object implements either :

javax.portlet.RenderRequest

or

javax.servlet.http.HttpServletRequest

how can I tell which it is?

I looked at obj.getClasses() no use provides a list of subclasses.
I looked at obj.getClassName() no use because it provides the
name of the concrete class not the interface.

Thanks




== 2 of 2 ==
Date: Fri, Dec 10 2004 7:49 pm
From: Sudsy  

[EMAIL PROTECTED] wrote:
> Example,
> 
> If an object implements either :
> 
> javax.portlet.RenderRequest
> 
> or
> 
> javax.servlet.http.HttpServletRequest
> 
> how can I tell which it is?
> 
> I looked at obj.getClasses() no use provides a list of subclasses.
> I looked at obj.getClassName() no use because it provides the
> name of the concrete class not the interface.
<snip>

Back to the books! The javadocs in this case. If you have an object
reference via the name obj then you can do the following:

Class k = obj.getClass();

Now research the Class#isAssignableFrom( Class k ) method.
Kewl, no?

-- 
Java/J2EE/JSP/Struts/Tiles/C/UNIX consulting and remote development.





==============================================================================
TOPIC: jdbc connect to mysql database
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/562500384f66e601
==============================================================================

== 1 of 1 ==
Date: Sat, Dec 11 2004 1:39 pm
From: Ian T  

Marcus Krieger wrote:

If you Read the first page of The Fine Documentation that comes with the 
official jdbc driver (www.mysql.com), you will find a code example that 
will work immediately. My java implementation would only work with the 
newInstance code below.

Something like:

try {
// The newInstance() call is a work around for some
// broken Java implementations
Class.forName("com.mysql.jdbc.Driver").newInstance();
  }
catch (Exception ex) {  // handle the error   }
java.sql.Connection c = 
DriverManager.getConnection("jdbc:mysql://localhost/recruitment?user=root&password=");
java.sql.ResultSet r = s.executeQuery("SELECT * FROM Candidates");
while ( r.next())
{
System.out.println(r.getString("fullname"));
System.out.println(r.getString("phone"));
}
s.close();
c.close();


Ian

> I am using JBuilder and I would like to connect to a mysql database.
> I was able to connect to a oracle database, however it does not work with
> mysql!
> I downloaded the newest drivers from the mysql webseite and put them into my
> java/bin directory.
> As I don't know exactly which java folder Jbuilder is using I have put them
> in both folder - my java folder and the java folder in jbuilder.
> Additionally, I tried to import the file from Jbuilder, and put them into
> "Project", "User Home" and "Jbuilder".
> 
> Whatever that exactly does, with oracle it had worked.
> Using mysql, I get the following error message:
> 
> driver:com.mysql.jdbc.Driver url:jdbc:mysql:
> java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
> java.sql.SQLException: No suitable driver
> java.sql.SQLException: No suitable driver
> 
> That's my code:
>                  [..]
>                 jdbc_driver="com.mysql.jdbc.Driver";
>                 db_login = "root";
>                 db_password = "";
>                 db_url = "jdbc:mysql://localhost:3306/dbname";
>                 try
>                 {
>                 Class.forName(jdbc_driver);
>                 }
>                  [..]
>                 DriverManager.getConnection(db_url, db_login, db_password);
> 
> Any ideas, what I am doing wrong here?
> 
> Thanks,
> 
> Marcus
> 
> 
> 




==============================================================================
TOPIC: Where do they go?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/13296f4262fb9757
==============================================================================

== 1 of 1 ==
Date: Sat, Dec 11 2004 4:07 am
From: "Michiel Konstapel"  

>> And of course mark/sweep GC makes perfect sense now...
>
> The janitor's name is Mark.

*grins*




==============================================================================
TOPIC: Advice on persistent storage in Java?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e1b92789433bcb07
==============================================================================

== 1 of 1 ==
Date: Fri, Dec 10 2004 9:09 pm
From: john martin  

I need some advice on persistent storage in Java. Basically, I'm writing 
an application that I'd like to be in pure Java (including any backend 
stuff it relies on, I'd like it to all run in the same VM). It has to 
store a potentially large data structure. I'd like to have as little 
hassle with SQL as possible, since I haven't done a ton of DB stuff, 
though it seems that it may be necessary, and so I'm not totally averse 
to using a regular SQL DB.

The two general options I'm considering are using an object oriented DB 
(e.g., PERST, http://www.garret.ru/~knizhnik/perst.html), and a regular 
SQL DB (e.g., hsqldb, http://hsqldb.sourceforge.net/).

Both PERST and hsqldb are pure Java, so that meets my first requirement 
(basically, I don't want someone to have to install a seperate DB 
product to run my app). I like the idea of using an OODB, but it's not 
totally transparent, and I won't be doing the most complex SQL in the 
world, so I'm not sure if it'll really save me any work. Has anyone had 
experience with either of the above tools? Anyone have any general 
advice for easily storing (possibly large) object oriented data 
structures in a way that's rather efficient and fault tolerant (i.e., 
not a flat text or XML file) but not a complete pain in the ass to 
implement?

Any advice from people who've either done object oriented DB stuff or 
who've had to bundle basic DB capability in a Java application would be 
much appreciated.

    -john




==============================================================================
TOPIC: Problem wtih Java ThreadGroup.activeCount method
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/80c6f5e77859ec02
==============================================================================

== 1 of 1 ==
Date: Sat, Dec 11 2004 3:14 am
From: Esmond Pitt  

As my example works as expected, the rational presumption at the moment 
is surely that there is a bug in your code rather than in ThreadGroup.

I don't know why Nimph mentions Thread.destroy(), this method is 
deprecated, doesn't do anything, and shouldn't be called.

Good luck.

avinashrk wrote:
> Hi Esmond
> 
> What you have here surely works and i am not contending that...but my
> code is not as simple as that..it has cloning involved and also
> implements thr unnavle interfae (these are the 2 main
> differences)...Now it might be bcos of these differences that I see the
> behavior of active count
> 
> In theory the behavior should be as your code shows but we see
> something different as did Nimph..so i want to know why that happened?
> 
> also keep in mind I am not a novice programmer and I have shown it to
> people with about 5 years of Java programming experience and they dont
> seem to see anything weird I might be doing..So all in all I think
> there is some problem with threadGroup which I dont know of





==============================================================================
TOPIC: JAVA/ ORACLE/ CONTRACT/ FL
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c2089808879d1377
==============================================================================

== 1 of 1 ==
Date: Sat, Dec 11 2004 3:28 am
From: "xarax"  

"Virgil Green" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> "Tom Gugger" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> >                                                          OMNI GROUP
> >
> >                                               [EMAIL PROTECTED]
> >
> >                                                          419-380-8853
> >
> >
> >
> >                                               J2EE/ JSP/ CONTRACT/ FL
> >
> >
> >
> > ORLANDO , FL
> >
> > EIGHT MONTHS
> >
> > Start Date: Jan 3, 2005
> >
> >  IMPORTANT: Contractor is required to provide laptop.
>
> Can't afford to provide the necessary hardware... but willing to pay
> contractor rates? Seems a bit odd.
>
> <snip job requirements>

IMPORTANT: EMPLOYER IS REQUIRED TO SPECIFY COMPENSATION OFFERED.






==============================================================================

You received this message because you are subscribed to the Google
Groups "comp.lang.java.programmer" group.

To post to this group, send email to [EMAIL PROTECTED] or
visit http://groups-beta.google.com/group/comp.lang.java.programmer

To unsubscribe from this group, send email to
[EMAIL PROTECTED]

To change the way you get mail from this group, visit:
http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe

To report abuse, send email explaining the problem to [EMAIL PROTECTED]

==============================================================================
Google Groups: http://groups-beta.google.com 

Reply via email to