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

Today's topics:

* newbie - jdbc Problem - 3 messages, 3 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3b61df05d633ffba
* JTextArea width problem - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5d52c11f1bcc3844
* Big Strings - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8d3a8b4e7997caff
* Why the method of concat() doesn't work? - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7c60d55d4b4874f1
* stubbing methods on test objexct with jMock - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b8c79c894a412218
* How to Store Network Path in Properties File? Backslash Weirdness. - 2 
messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8e5fc43ddff56cea
* Why the method of concat(String str) in String Class doesn't work? - 1 
messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3f3694bc9d4d3d6
* Is it possible to set a block of code as non-JIT area? - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/efa6df384a75654c
* Big Strings in java - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/917e13797df1e216
* Terminating a process tree - 2 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d7dd1ce1cb22f1ca
* jdbc new types - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4fa7de2791643843
* Invalid Trademark Character Saved in Oracle - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b03bcf2882945102
* C++ to Java - 2 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5091648c9abcffb0
* Using Java from C++ application - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e884a847bbbc4a70
* Java SDK International Edition - 2 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/27890d598fe84351
* Which design pattern? - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7b478a81ece717c8
* Object reference side effects - desirable? - 2 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/294afbcaabeb8325
* Can't display Java gui - 2 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/70509f2693ffc62a
* MIDlet Design Question - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/45f298001caa915e
* Help:package javax.servlet.http does not exist - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e22f374e7122da1a
  
==========================================================================
TOPIC: newbie - jdbc Problem
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3b61df05d633ffba
==========================================================================

== 1 of 3 ==
Date:   Mon,   Nov 8 2004 12:20 pm
From: [EMAIL PROTECTED] (Xarky) 

After fixed the PreparedStatment by removing the ?, an error is being
given at
run time.

The error is given -
java.sql.SQLException: [Microsoft][ODBC Microsoft Access
Driver]Attribute cannot be set now
java.sql.SQLException: [Microsoft][ODBC Microsoft Access
Driver]Attribute cannot be set now
       at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6879)
       at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7036)
       at sun.jdbc.odbc.JdbcOdbc.SQLSetConnectOption(JdbcOdbc.java:5068)
       at 
sun.jdbc.odbc.JdbcOdbcConnection.setAutoCommit(JdbcOdbcConnection.java:651)
       at DatabaseManager.Transactions(DatabaseManager.java:189)
       at Launcher.main(Launcher.java:13)



"Andy Flowers" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
> PreparedStatement ps = con.prepareStatement ("UPDATE ?HoursLog SET hours = ? 
> WHERE programmer = 'Pete'");
> 
> The first ? (making ?Hourslog) is not required I believe ?
> 
> What error are you receiving ? Is it an exception or a compile time error ?
> 
> If it's an exception can you post the details.



== 2 of 3 ==
Date:   Mon,   Nov 8 2004 1:21 pm
From: "Andy Flowers" <[EMAIL PROTECTED]> 

Looks like it's an ordering problem related to the driver and how it talks 
down to ODBC/Access.

Try moving the con.setAutoCommit(true); to be the first database statement 
you use.

"Xarky" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> After fixed the PreparedStatment by removing the ?, an error is being
> given at
> run time.
>
> The error is given -
> java.sql.SQLException: [Microsoft][ODBC Microsoft Access
> Driver]Attribute cannot be set now
> java.sql.SQLException: [Microsoft][ODBC Microsoft Access
> Driver]Attribute cannot be set now
>       at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6879)
>       at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7036)
>       at sun.jdbc.odbc.JdbcOdbc.SQLSetConnectOption(JdbcOdbc.java:5068)
>       at 
> sun.jdbc.odbc.JdbcOdbcConnection.setAutoCommit(JdbcOdbcConnection.java:651)
>       at DatabaseManager.Transactions(DatabaseManager.java:189)
>       at Launcher.main(Launcher.java:13)
>
>
>
> "Andy Flowers" <[EMAIL PROTECTED]> wrote in message 
> news:<[EMAIL PROTECTED]>...
>> PreparedStatement ps = con.prepareStatement ("UPDATE ?HoursLog SET hours 
>> = ?
>> WHERE programmer = 'Pete'");
>>
>> The first ? (making ?Hourslog) is not required I believe ?
>>
>> What error are you receiving ? Is it an exception or a compile time error 
>> ?
>>
>> If it's an exception can you post the details. 





== 3 of 3 ==
Date:   Mon,   Nov 8 2004 1:43 pm
From: steve <[EMAIL PROTECTED]> 

On Mon, 8 Nov 2004 19:13:16 +0800, Xarky wrote
(in article <[EMAIL PROTECTED]>):

> Hi,
>    I added the PreparedStatment, and it seems to work till that part. 
> Now, at runtime it is failing on line
>    con.setAutoComit(false);
> 
> 
> 
> public void Transactions()
> {
>       ResultSet result = null;
>       String query01 = null;
>       boolean flag;
>       int data=0;
>                               
>       query01 = "SELECT hours FROM HoursLog WHERE programmer='Pete'";         
>       System.out.println ("Trying to make a transaction on HoursLog
> table.");
>       try
>       {
>               PreparedStatement ps = con.prepareStatement ("UPDATE ?HoursLog 
> SET
> hours = ? WHERE programmer = 'Pete'");
>               con.setAutoCommit(true);                
>               result = stmt.executeQuery (query01);
>               flag = result.next();
>               if (flag)
>               {       
>                       data = result.getInt("hours");
>                       data = data + 2;
>                       ps.setInt(1,data);                                      
>                 
>                       ps.executeUpdate();
>               } // end if
>               else
>               {
>                       System.out.println ("Data searched not found.");
>               } // end else
>                       System.out.println ("11");
>               
>               con.setAutoCommit(false);
>               System.out.println ("Transaction on HoursLog table completed.");
>       } // end try statment
>       catch(SQLException e)
>       {
>               System.err.println ("DatabaseMangager.Transactions() - 
> Encountered
> SQLException while trying to make a transaction on HoursLog table.");
>               System.err.println (e);                 
>               e.printStackTrace();
>               System.exit(16);
>       } // end catch statment
> } // end method Transactions
> 
> 
> "Andy Flowers" <[EMAIL PROTECTED]> wrote in message 
> news:<[EMAIL PROTECTED]>...
>> As identified in another post, the statement
>> query02 = "UPDATE HoursLog SET hours ="+ data+ "WHERE 
>> programmer='Pete'";
>> will fail as it will produce incorrect SQL.
>> 
>> Also even if this is fixed in your code the hours will ALWAYS be 0 as the 
>> SQL string will be generated before you have read and set up data.
>> 
>> A simple, and better, way to get around this is to use a PreparedStatement 
>> such as
>> 
>> // initialise a prepared statement
>> PreparedStatement ps = con.prepareStatement("UPDATE HoursLog SET hours=? 
>> WHERE programmer=?");
>> 
>> // read data (and possibly the programmer to update)
>> ....
>> 
>> // and then set the values you have read into the prepared statement
>> ps.setInt(1, data);       // hours to set
>> ps.setString(2, "pete"); // programmer to update
>> 
>> // and finally execute the update
>> ps.executeUpdate();
>> 
>> Using a prepared statement will allow you to create the statement in some 
>> initialisation block, such as where you create the connection, and then 
>> have 
>> it reused by setting the parameters as needed.
>> 
>> See the API documentation for more info at 
>> http://java.sun.com/j2se/1.5.0/docs/api/java/sql/PreparedStatement.html
>> and also http://java.sun.com/docs/books/tutorial/jdbc/basics/prepared.html
>> 

DO NOT play with the "auto commit" flag during a transaction.

set the  "con.setAutoCommit(false);             " at the very start , just 
after opening 
the connection .
then use

con.commit();  //to commit stuff  to the database or
con.rollback();  //to cancel it





==========================================================================
TOPIC: JTextArea width problem
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5d52c11f1bcc3844
==========================================================================

== 1 of 1 ==
Date:   Mon,   Nov 8 2004 12:25 pm
From: "Ann" <[EMAIL PROTECTED]> 


"Neutrino" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hello,
> I am using a JTextArea to display 10 lines with a maximum of 40
characters,
> so I created a JTextArea (10, 40). It is working correctly excepted the
fact
> that the width of the text area is doubled under KDE  compared to XP
Windows
> look-and-feel. With windows the width is closed to the correct size (I
mean
> 40 characters fill the area quite correctly), but with Linux KDE, I can
> input quite 80 characters and the area is very large. I understand that
for
> fonts size compatibilities and portability reasons the size could be
> different than 40 characters but a so important difference, I do not
> understand ? with other words, is there somewhere an description for what
is
> the meaning of the parameter 'column' of the JTextArea constructor ?
> Best Regards,
> AR
>

The layout manager might make it wider for you.






==========================================================================
TOPIC: Big Strings
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8d3a8b4e7997caff
==========================================================================

== 1 of 1 ==
Date:   Mon,   Nov 8 2004 12:36 pm
From: "Ann" <[EMAIL PROTECTED]> 


"Randy Dizitser" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I have a string thats larger then the maximum size that the String
> class can accomodate. Is there a way to still store my string as one
> string?

same way you put 6 elephants in a volkswagen
(3 in the front, 3 in the back)   ;-)






==========================================================================
TOPIC: Why the method of concat() doesn't work?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7c60d55d4b4874f1
==========================================================================

== 1 of 1 ==
Date:   Mon,   Nov 8 2004 12:41 pm
From: Bryce <[EMAIL PROTECTED]> 

On 7 Nov 2004 04:58:28 -0800, "Bruce Sam" <[EMAIL PROTECTED]>
wrote:

>Below is my simple java program:
>/* **************************************** */
>public class MyString {
>public static void main(String[] args) {
>String str1 = "BCDE";
>System.out.println(str1);
>String str2 = "A";
>System.out.println(str2);

instead of this:
>str2.concat(str1);
^^^^^^^^^^^^^

do this:

str2 = str2.concat(str1);

>System.out.println(str2);
>}
>}
>/* **************************************** */
>I think the run result should be as:
>BCDE
>A
>ABCDE
>But in fact,it is:
>BCDE
>A
>A
>Why the method of concat() doesn't work?What I hope to do is only to
>concatenate the str1 to the end of str2;


--
now with more cowbell




==========================================================================
TOPIC: stubbing methods on test objexct with jMock
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b8c79c894a412218
==========================================================================

== 1 of 1 ==
Date:   Mon,   Nov 8 2004 12:40 pm
From: Bryce <[EMAIL PROTECTED]> 

On 7 Nov 2004 05:02:15 -0800, [EMAIL PROTECTED] (PeterS) wrote:

>I am using jMock for doing my unit tests and it works fine. But there
>is one point I do not know how to solve it. I want to test a method (
>e.g. "testMethod")in my object which calls another method (e.g.
>"anotherMethod") of the same object. I do not want to execute
>anotherMethod it´s own code. Instead it shall return a value
>controlled by the test case class. Can someone tell me what I have to
>do to achieve this aim with jMock?

I'm not sure what you are trying to do.

I think you are saying that you have a class, like this:

public class MyClass {
  public void testMethod() {
    String temp = anotherMethod();
  }

  public String anotherMethod() {
  ....
  }
}

Is this the case?

Then, assuming you are testing MyClass, its not possible to do it as
written. However, if you've written your class in another way you
could (I'm throwing this together quickly, so it may not compile, but
gives you an outline):

public class MyClass {
  private AnotherClass anotherClass;

  public void setAnotherClass(AnotherClass ac) {
    this.anotherClass = ac;
  }

  public void testMethod() {
    String temp = anotherClass.anotherMethod();
  }
}

public interface AnotherClass {
  public String anotherMethod();
}

public class AnotherClassImpl implements AnotherClass {
  public String anotherMethod() {
  ...
  }
}

Then, your test code would look like this:

public class TestMyClass extends MockObjectsTestCase{
  public void testTestMethod() {
    MyClass myClass = new MyClass();

    Mock mock = new Mock(AnotherClass.class);
    myClass.setAnotherClass((AnotherClass)myClass.proxy);
   

mock.expects(once).method("anotherMethod").withNoArguments().will(returnValue("testString));

   myClass.testMethod();

   mock.verify(); 
  }
}

I suppose an easier way to do it, without using Mocks is to just
subclass your class, and override the method you need to.:

public class MyClassMock extends MyClass {
  public String anotherMethod() {
    return "Hard coded string";
  }
}



--
now with more cowbell




==========================================================================
TOPIC: How to Store Network Path in Properties File? Backslash Weirdness.
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8e5fc43ddff56cea
==========================================================================

== 1 of 2 ==
Date:   Mon,   Nov 8 2004 2:15 pm
From: [EMAIL PROTECTED] (Skinny Guy) 

How can I store and correctly read back a network path in a Properties
file?

\\servername\\sharename\directory\

I tried different combinations of backslashes, then tried to escape
the last backslash (because its the Properties continuation char), but
none of my combinations worked after reading the property back into a
string.

I want to read it back into a String so that the String will contain
the exact characters above. How should the property look in the
Properties file?



== 2 of 2 ==
Date:   Mon,   Nov 8 2004 2:52 pm
From: Carl <[EMAIL PROTECTED]> 

Skinny Guy wrote:

> How can I store and correctly read back a network path in a Properties
> file?
> 
> \\servername\\sharename\directory\
> 
> I tried different combinations of backslashes, then tried to escape
> the last backslash (because its the Properties continuation char), but
> none of my combinations worked after reading the property back into a
> string.
> 
> I want to read it back into a String so that the String will contain
> the exact characters above. How should the property look in the
> Properties file?

This works for me by escaping the backslash chars. "\" becomes "\\", and 
"\\" becomes "\\\\".

In the props file, it should appear as:
netPath=\\\\server\\share\\directory\\

example:

        Properties props = new Properties();
        Properties propsIn = new Properties();
                
        String pathString = new String("\\\\server\\share\\directory\\");
        
        props.put("netPath", pathString);
                
        try{
                File file = new java.io.File(System.getProperty("user.home"), 
"test.file");
        
                if(!file.exists()){
                        file.createNewFile();
                }
        
                FileOutputStream fos = new FileOutputStream(file);
                props.save(fos, "test");
                propsIn.load(new FileInputStream(file));
        
        } catch (FileNotFoundException e){
                e.printStackTrace();
        } catch (IOException e){
                e.printStackTrace();
        }
        
        System.out.println("Read: " + propsIn.get("netPath"));




==========================================================================
TOPIC: Why the method of concat(String str) in String Class doesn't work?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3f3694bc9d4d3d6
==========================================================================

== 1 of 1 ==
Date:   Mon,   Nov 8 2004 2:38 pm
From: Sudsy <[EMAIL PROTECTED]> 

John C. Bollinger wrote:
<snip>
> assuming that the += construct caused the left-hand String to be 
> modified, and therefore that Strings were mutable.

Good point! People don't always recognize when new objects are
created. Perhaps I contributed to the confusion?
John is, as always, correct and the clarification should provide
guidance as to the proper use of methods returning references
and language constructs which perform essentially the same thing.

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





==========================================================================
TOPIC: Is it possible to set a block of code as non-JIT area?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/efa6df384a75654c
==========================================================================

== 1 of 1 ==
Date:   Mon,   Nov 8 2004 2:43 pm
From: "John C. Bollinger" <[EMAIL PROTECTED]> 

jacksu wrote:

> Actually our application crashes at one point, and that point has been
> obsuficated. We think disable JIT on that portion of code may help.

Although it is conceivable that you have hit a JIT bug, it is far more 
likely that your code is buggy (perhaps made so by the obfuscator).  If 
the obfuscated and non-obfuscated codes produce different behavior then 
your obfuscator is broken, in which case the solution is to either 
abandon obfuscation or get a better obfuscator.  If they produce the 
same behavior then the obfuscation is not relevant.


John Bollinger
[EMAIL PROTECTED]




==========================================================================
TOPIC: Big Strings in java
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/917e13797df1e216
==========================================================================

== 1 of 1 ==
Date:   Mon,   Nov 8 2004 2:48 pm
From: "John C. Bollinger" <[EMAIL PROTECTED]> 

Chris Smith wrote:

> Stefan Schulz wrote:
> 
>>Well, the largest String my machine can create is a whopping
>>268435456 chars long... That is 512 MB. Are you sure your String
>>is that long, and _needs_ to be that long?
>>
>>Also, i am pretty sure that this is not a limitation of the String
>>class, but rather that my PC ran out out memory (the test program
>>failing with a OutOfMemoryError seems to indicate it ;) )
> 
> 
> Yes, you are correct.  The actual limit is 2^31 - 1, or about two 
> billion, characters long.  Note that some APIs (such as 
> DataOutputStream's writeUTF) may require a shorter length (in that 
> example, 2^16 - 1, or about 64K, characters).

And Java chars are two bytes wide, hence the size of the maximal String 
is 4GB.  To the OP: come up with a different way to accomplish your 
goal.  If you tell us what that is then we may be able to help you, but 
flagrant consumption of system resources is rarely, if ever, a sign of 
good program design.


John Bollinger
[EMAIL PROTECTED]





==========================================================================
TOPIC: Terminating a process tree
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d7dd1ce1cb22f1ca
==========================================================================

== 1 of 2 ==
Date:   Mon,   Nov 8 2004 3:13 pm
From: "John C. Bollinger" <[EMAIL PROTECTED]> 

Wayne Marrison wrote:

> "John C. Bollinger" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
> 
>>Wayne Marrison wrote:
>>
>>
>>>I have been programming in java for about 2 months, and am currently 
>>>trying
>>>to control an external application that I start using:
>>>
>>>Process proc;
>>>Runtime rt;
>>>
>>>proc = rt.exec("java.exe -cp ... etc.. something");
>>>
>>>Then I capture the input/output & error streams and thread them off.
>>
>>No detail there, but it sounds like a correct approach.  Do you really 
>>need to spawn a new VM for this, though?  Perhaps there are reasons why 
>>you do need to do (or at least, reasons why it's convenient), but in many 
>>cases it would work as well or better to just start up a new thread in the 
>>current VM for an "external" Java process.
> 
> 
> If you can point me in the right direction for an example on how to do this, 
> it would be appreciated.  I'm still very new to this, but have deadlines to 
> attempt to meet.

All you need to do to start a Java program is invoke the static main() 
method of its main class.  You can do that from any Java code:

void startExternalApp(String[] args) {
     ExternalApp.main(args);
}

If you want to make the external app use its own ClassLoader (so as to 
segregate its classes from your launcher app's own, and also from those 
of any other instance your launcher starts, then you would need to get a 
bit fancier.  You would instantiate the ClassLoader (probably an 
instance of URLClassLoader; make sure it points to a suitable parent 
ClassLoader) use it to load the correct Class, then look up the correct 
main() Method in the Class object and invoke it.  The Class and Method 
classes are part of the Java "Reflection" API -- you should generally 
avoid them unless you need them, but this is a case where you would need 
them.

You can take one more step and assign the external app to its own 
thread.  The easiest way to do this would be something like:

Thread startExternalAppInThread(final String[] args) {
     ClassLoader cl = new URLClassLoader(/* your args here*/);
     Class appClass = cl.findClass("fully.qualified.name");
     final Method mainMethod =
         appClass.getMethod("main", new Class[] {args.getClass()});

     return new Thread() {
         public void run() {
             mainMethod.invoke(null, new Object[] {args});
         }
     }
}

Note that I'm typing quickly, so don't assume that that's all kosher, 
but it should give you an idea.

>>If the external process is unable to respond to requests then it may be in 
>>a state where it is unable to respond to the OS' normal signals to shut 
>>down, either.
> 
> 
> Using O/S tools works fine to kill the remaining java.exe.

The OS' tools may include both a "soft" kill and a hard "kill".  Java 
implementations are unlikely to perform the latter because it may not be 
safe.  The former, however, may not work if the process is badly hung.


John Bollinger
[EMAIL PROTECTED]




== 2 of 2 ==
Date:   Mon,   Nov 8 2004 6:44 pm
From: marcus <[EMAIL PROTECTED]> 

Hey Wayne,
Since you agree this isn't the correct way to do it and you need a hack, 
I can suggest one that has worked for me in FreeBSD (should work in any 
linux type environment).  Instead of launching the second java program 
directly I used a control script (stolen from my apache setup, I think) 
that records the PID in a dedicated text file.  When I needed to kill it 
I invoked the control script, which issued the OS kill command on the 
recorded PID.  Kills it dead as far as I know.


Wayne Marrison wrote:
> (posted yesterday in comp.lang.java.help, but not sure if that was the right 
> place and had no response, so posting in here today, sorry for the 
> additional bandwidth to those that subscribe to both groups)
> 
> Hi group,
> 
> I'm new here, so apologies if I ask this in the wrong way.
> 
> I have been programming in java for about 2 months, and am currently trying
> to control an external application that I start using:
> 
> Process proc;
> Runtime rt;
> 
> proc = rt.exec("java.exe -cp ... etc.. something");
> 
> Then I capture the input/output & error streams and thread them off.
> 
> The problem I have, is that I need to architect for the eventuality of the
> external process locking up and not responding to requests.  I have the
> whole capturing of streams in a timeout, so I can tell when the external
> program has not responded within a reasonable time, however when I issue the
> proc.destroy() method, the java.exe process takes up almost 100% cpu and
> never stops.  I have to use operating system tools to perform a manual kill
> of the process.
> 
> I can only assume that the proc.destroy() doesnt kill the entire process
> tree, and because the command line starts off java.exe, which runs the
> something.class file, a process is orphaned somewhere.
> 
> Any help would be much appreciated.
> 
> Thanks
> 
> Wayne
> 
> 





==========================================================================
TOPIC: jdbc new types
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4fa7de2791643843
==========================================================================

== 1 of 1 ==
Date:   Mon,   Nov 8 2004 3:42 pm
From: Lee Fesperman <[EMAIL PROTECTED]> 

Juan wrote:
> 
> I'm looking for a database system other than Oracle that supports the jdbc
> 2.0 types Array, Struct and so on.

Our product, FirstSQL/J (see my sig.), supports user-defined Java classes as 
datatypes. 
You can define classes that implement java.sql.Array and java.sql.Struct (et 
al) and 
import them into the database as datatypes. Our JDBC driver supports 
getArray()/setArray() and getStruct()/setStruct() on those user-defined objects.

-- 
Lee Fesperman, FFE Software, Inc. (http://www.firstsql.com)
==============================================================
* The Ultimate DBMS is here!
* FirstSQL/J Object/Relational DBMS  (http://www.firstsql.com)




==========================================================================
TOPIC: Invalid Trademark Character Saved in Oracle
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b03bcf2882945102
==========================================================================

== 1 of 1 ==
Date:   Mon,   Nov 8 2004 3:46 pm
From: [EMAIL PROTECTED] (Neel Gutierrez) 

We are experiencing a problem with invalid characters being saved thru
a java-based web application in the Oracle database for some special
characters that were copied and pasted from a Microsoft Word file. 
One of the requirements of the application is the ability to
cut-and-paste text from Word and save it into the database.  But for
some reason the trademark and ellipsis symbol are not being saved
correctly…they are getting converted to a value that is equivalent to
an inverted question mark instead.  And because of this when you view
text that has these symbols using a reporting tool such as Actuate,
the invalid character is displayed instead.  There is no problem
displaying these characters back to the user…that is, if/when the
application reads it from the database and displays it to the user
thru JSP pages.  Has anyone come across this problem before?  Any
suggestions and/or recommendations as how to fix it? So far I've tried
the line of code:  request.setcharacterencoding("utf-8)...still does
not fix the problem.  Appreciate any help.




==========================================================================
TOPIC: C++ to Java
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5091648c9abcffb0
==========================================================================

== 1 of 2 ==
Date:   Mon,   Nov 8 2004 4:38 pm
From: "<- Chameleon ->" <[EMAIL PROTECTED]> 

How can I write this in Java?

void change(string &s) {}


and how can I write this in Java?

void change(string s) {}



Because all Object in Java are passed by reference in functions, the 
following Java code is equal to 1st C++ code, up.

void change(String s) {}

but with a test, I discover that this code is equal to 2nd C++ code.

Any help?

Thanks!



== 2 of 2 ==
Date:   Mon,   Nov 8 2004 5:09 pm
From: "KC Wong" <[EMAIL PROTECTED]> 

Version 1:
> void change(string &s) {}

Version 2:
> void change(string s) {}

> Because all Object in Java are passed by reference in functions, the
> following Java code is equal to 1st C++ code, up.

That's incorrect.

> void change(String s) {}
>
> but with a test, I discover that this code is equal to 2nd C++ code.

- Java pass parameters to functions by value
- java.lang.String objects are immutable. Once created, it cannot be
changed. When you do a String assignment,
e.g. String s = "ABC";  s = "DEF";
You're not changing the string "ABC" to "DEF"... instead, you're just
creating a new String object instance containing the value "DEF" and point
String variable s at it.

So to change a String, you get a copy from the parameter, change it, and
return a String. There're plenty of examples in the core API... see the API
documentation of java.lang.String for method trim().

Or if you really, *really*, REALLY must return void (and I don't know why
you must), then you can use a String array to do it. But that's very ugly,
very dirty code.

e.g. void change(String[] s)






==========================================================================
TOPIC: Using Java from C++ application
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e884a847bbbc4a70
==========================================================================

== 1 of 1 ==
Date:   Mon,   Nov 8 2004 4:51 pm
From: "ZX" <[EMAIL PROTECTED]> 

Non-GUI:
Is there a way to call Java functions from C++ application?

GUI:
Can I use Java GUI modules from C++ application? In other words, has anyone
tried to integrate parts of GUI written in Java and  the parts built using 
some native GUI tool such as Borland C++ Builder or MSVC/MFC? It is 
pereferable that the resulting application looked like an integral whole. 
If it is not possible then at the very least I need an ability to display 
Java dialogs from legacy application and pass the user's input to the 
"enclosing" application






==========================================================================
TOPIC: Java SDK International Edition
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/27890d598fe84351
==========================================================================

== 1 of 2 ==
Date:   Mon,   Nov 8 2004 5:32 pm
From: "JamesY" <[EMAIL PROTECTED]> 

"Lothar Kimmeringer" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Mon, 8 Nov 2004 14:49:37 +0800, JamesY wrote:
>
> > I couldn't find the above mentioned SDK at www.sun.com. Anyone can
provides
> > a link to it? Thanks
>
> What should it contain? I18N is part of the standard SDK.
>
>
> Regards, Lothar
> -- 
> Lothar Kimmeringer                E-Mail: [EMAIL PROTECTED]
>                PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81)
>
> Always remember: The answer is forty-two, there can only be wrong
>                  questions!
>

Well, I thought there is an international version of the SDK, but I am
wrong.
Thanks Lothar for the reply.





== 2 of 2 ==
Date:   Mon,   Nov 8 2004 5:30 pm
From: "JamesY" <[EMAIL PROTECTED]> 


"Tor Iver Wilhelmsen" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> "JamesY" <[EMAIL PROTECTED]> writes:
>
> > I couldn't find the above mentioned SDK at www.sun.com. Anyone can
provides
> > a link to it? Thanks
>
> Only the JRE has a "international" version. The JDK/SDK has the
> international JRE built-in, as another poster commented.

Thanks alot Tor ;-)






==========================================================================
TOPIC: Which design pattern?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7b478a81ece717c8
==========================================================================

== 1 of 1 ==
Date:   Mon,   Nov 8 2004 5:38 pm
From: Nevermind <[EMAIL PROTECTED]> 

Hi All,

I would like my application (which access the system clipboard and the 
file system) to work a regular desktop application and a JNLP 
application, so there will be some sort of two sets of code, one set 
specific for the case of regular app and the other specific for the case 
of JNLP app.

Which design pattern should I pick (Factory Method, Abstract Factory,...)?

Your help will be appreciated so much!




==========================================================================
TOPIC: Object reference side effects - desirable?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/294afbcaabeb8325
==========================================================================

== 1 of 2 ==
Date:   Mon,   Nov 8 2004 5:45 pm
From: Michael Rauscher <[EMAIL PROTECTED]> 

VisionSet wrote:
> "Michael Rauscher" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> 
>>And
>>if one needs a copy of a domain object, he has to ask the control object
>>to return one...
>>
> 
> 
> Thanks.
> 
> Should the word 'copy' be stressed here.

Maybe :-)

Imagine a simple address form. If the control object would return the 
"real" address object, the form may directly manipulate it.

IMHO, the situation should be something like this:

User wants to edit address 235, he executes the "Edit Address Use Case".

The use case object requests a copy of address 235 from the "Edit 
Address Control Object" and creates a form object (the view) that 
displays the address (the model) and allows the user to manipulate 
(controllers) the form's fields.

If the user decides to save the changes, the use case asks the form 
object to save it's state to the model (maybe there's a method called 
viewToModel) and sends an update message to the control object.

If the user decides not to save the changes he made, the use case simply 
closes the form and everything is fine ;-)

> 
> --
> Mike W
> 
> 

Bye
Michael



== 2 of 2 ==
Date:   Mon,   Nov 8 2004 6:09 pm
From: Michael Rauscher <[EMAIL PROTECTED]> 

VisionSet wrote:
> "Michael Rauscher" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> 
> And another question.  Where does the reference to the base domain objects
> go?
> eg Accounts can be aggregated in a collection class, but where does the
> (base) collection object reference go?  Do I have a DomainSingleton class
> and put my base collection object in that?  Certainly doesn't seem right to
> put in a control object.

Depends on your needs. But don't try to put everything into one class. 
There would be too much coupling.

The control object may use simply an "Addresses" singleton or an 
Address-DAO.

E.g.

public class Address {
     //...
     public Address() {}
     public Address( Address toCopy ) { /* ... */ }
}

public class Addresses {
     private static final Addresses instance = new Addresses();

     // ...

     private Addresses() {}
     public Address getAddressByID( int id ) { /* ... */ }
     public void replace( Address a, Address b ) { /* ... */ }
}

Then, the control class may implement something like

public Address getAddress( int id ) {
     return new Address( Addresses.getAddressByID(id) );
}

public void update( Address address ) {
     Address realAddress = Addresses.getAddressByID(address.getID());
     Addresses.replace( realAddress, address );
}

> 
> --
> Mike W
> 
> 
Bye
Michael




==========================================================================
TOPIC: Can't display Java gui
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/70509f2693ffc62a
==========================================================================

== 1 of 2 ==
Date:   Mon,   Nov 8 2004 6:17 pm
From: [EMAIL PROTECTED] (Conrad Eaglehill) 

"John C. Bollinger" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL 
PROTECTED]>...
> Are you fork()ing a new process in which to launch the GUI?

Sort of. I'm using a system() call.

> You ought 
> to be able to have that process change its euid and egid to 
> non-privileged ones, prior to exec()ing the JVM. 

I tried that, but the message remains the same. Interestingly, when I
call setuid() or seteuid() in my dummy program, I get the same sets of
errors, though without these calls, the Java app comes up just fine.

> Also, some of the 
> various exec calls allow you to specify the environment for the new 
> executable; this avoids unnecessarily propagating environment variables, 
> as well as giving you an easy hook for inserting new variables required 
> by the exec()ed program.
> 
> Or are you running it via the system() call?  That's basically a wrapper 
> around the exec()-based technique; you could write your own replacement 
> that does what you want.

I am actually using a system() call, and I thought about exec()ing,
but system() returns a value, whereas exec() calls never return. I use
the return value of the Java app to make decisions.

> Alternatively, if you're spawning the Java 
> program that way then you may want to look into using su -c.

This is interesting. In my dummy program as ceaglehill (my account)...
"su -c ./dummy ceaglehill" => works when I enter a password
"su -c ./dummy root"       => works when I enter a password

But as root...
"su -c ./dummy root"       => works perfectly without password
"su -c ./dummy ceaglehill" => fails, giving me the same errors as
above

Of course, it is the last than I need. :-( Definitely good ideas,
though. I hadn't thought about "su -c" or the setuid() calls until you
brought them up. Any other tricks up your sleeve? :-)

> John Bollinger
> [EMAIL PROTECTED]

Conrad Eaglehill



== 2 of 2 ==
Date:   Mon,   Nov 8 2004 6:20 pm
From: [EMAIL PROTECTED] (Conrad Eaglehill) 

Thomas Weidenfeller <[EMAIL PROTECTED]> wrote in message news:<[EMAIL 
PROTECTED]>...
> Conrad Eaglehill wrote:
> > Looking into the problem, I found that when running as root, lots of
> > people have had the same problem, and their solution was "don't run as
> > root." Sendmail needs root permissions for some things, so this isn't
> > an option for me. I wonder if anyone know how to run a Java
> > application that needs the X-Window server as root, (or perhaps would
> > allow me to run a Java gui from sendmail as another user temporarily).
> 
> I can't really see why anyone would like to start a GUI from a 
> background daemon like sendmail (especially, because there is no 
> guarantee that anyone is looking at the display), but well ...
> 
> To change your effective user user id, see:
> 
> man su
> man sudo

"su -c progname username" works, sort of. When I'm root, and I try to
execute this program as another user, I get the same errors. When I am
a user and I try to execute the program as root, it works fine, except
I have to enter a password.

> But if you really need to alert someone from sendmail (why?), consider 
> using something like wall or syslog, or sending a pager/SMS message.

Alas, I don't have a choice in the matter. As amm people, I do as I'm
told. The app isn't a logger, though. It displays visual info to the
user, and thus has to be a gui.

Thanks for the response, though!

> /Thomas

Conrad Eaglehill




==========================================================================
TOPIC: MIDlet Design Question
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/45f298001caa915e
==========================================================================

== 1 of 1 ==
Date:   Mon,   Nov 8 2004 6:26 pm
From: JScoobyCed <[EMAIL PROTECTED]> 

Rhino wrote:
> ...
> 
>  if (label.equals(CANCEL_INSERT_TEXT)) {
>   System.out.println(CLASS_NAME + "." + METHOD_NAME + " - User chose " +
> CANCEL_INSERT_TEXT + ".");
>   String msg = "Insert Cancelled.";
>   Alert cancelled = new Alert("Action", msg, null, AlertType.INFO);
>   cancelled.setTimeout(5000); //milliseconds
>   display.setCurrent(cancelled);
>   return;
>   }

Hi,

    the code above siply says how to "dispose" of the Alert, not how to 
display the current form. The Display class also accept another 
setCurrent(Alert, Displayable) method. When the Alert disappear, the 
second parameter will be set as current screen. If your second parameter 
is the Displayable object that render the member list, then you will
have the expected result. But as I understand, the MemberManager is your 
MIDlet, and it doesn't subclass Displayable.


> My main class, MemberManager class, extends MIDlet. My supporting class,
> MemberAddForm, extends Form. Is that the right approach or should
> MemberAddForm also extend MIDlet? Is that my problem? If MemberAddForm also
> extended MIDlet, I could destroy it when I am done with it. I'm a little
> confused because my approach in J2SE would be to make MemberAddForm a dialog
> that is initiated by a Frame but J2ME doesn't seem to have the concept of a
> dialog.
> 
> Can anyone shed some light on this for me?
> 

Well, I wouldn't recommand the MIDlet (MemberManager) to be the class 
that displays the list of member. Instead, it would be preferrable to 
have a subclass of Form as well. In the MIDlet, just call 
display.setCurrent(MemberManager) at startup, or even better, on the 
action of a button. And then, for your alert, you can do:
display.setCurrent(canceled,memberManager);
Note that this will work only if canceled has no CommandListener except 
the default one (that is, you don't explicitly provide a CommandListener 
on the Alert).

JScoobyCed




==========================================================================
TOPIC: Help:package javax.servlet.http does not exist
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e22f374e7122da1a
==========================================================================

== 1 of 1 ==
Date:   Mon,   Nov 8 2004 6:57 pm
From: [EMAIL PROTECTED] (SAMBA) 

Hi,
can some one help me please.
i have tomcat 5.0 and mysql 1.4
my problem is: this message
"package javax.servlet.http does not exist"
all solution i found it was with servlet.jar
but this file does not exist in tomcat 5.0 
can any one have ideas
thanx



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

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

comp.lang.java.programmer
[EMAIL PROTECTED]

Change your subscription type & other preferences:
* click http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe

Report abuse:
* send email explaining the problem to [EMAIL PROTECTED]

Unsubscribe:
* click http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe


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

Reply via email to