Re: String manipulation
On 2000-07-05 12:42:21 -0700, Man Chi Ly wrote:
> On Wed, 5 Jul 2000, Tony J. Paul wrote:
> > it like this,
> >
> > StringBuffer sb=new StringBuffer();
> > sb.append("SELECT COF_NAME, ");
> > sb.append("SALES FROM COFFEES ");
> > stmt.executeQuery(sb.toString());
>
> I recall reading somewhere that the following code is optimized by javac
> (roughly) into the form you provided just above:
>
> String s;
> s = "SELECT COF_NAME, ";
> s += "SALES FROM COFFEES ");
> s += "WHERE COF_NAME = 'Starbucks'";
> stmt.executeQuery(s);
>
> In other words, the compiler optimizes successive calls to the += operator
> into StringBuffer.append() calls without creating a bunch of intermediate
> objects. Does javac actually do this, or do I need to go back to the ugly
> StringBuffer idiom for efficiency?
Newer versions of javac do this. But they start with a
StringBuffer with default size (which is 16 characters). Since
the cost of expanding a StringBuffer is quite high and this will
happen often if you concatenate large strings, doing it yourself
with a initially large StringBuffer is faster.
Best regards
Martin
P.S.: Please read http://members.aol.com/intwg/guide.htm
--
Martin Schröder, [EMAIL PROTECTED]
ArtCom GmbH, Grazer Straße 8, D-28359 Bremen
Voice +49 421 20419-44 / Fax +49 421 20419-10
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: Where can I download a complete Java-Linux source codes?
Yes, I need the source code for my MSc research. I would like to modify the JDK for real-time in some aspects. I have the binary version of the JDK downloaded from www.blackdown.org. (JDK 1.2.2. RC4) I also have the source code version of the JDK downloaded from www.sun.com, but I cannot rebuild it on my Linux Box (Mandrake 7.0) Could you please let me know where I can get a complete source code version for JDK 1.2.2 RC4 for Linux. Many thanks. Erik On Thu, 06 Jul 2000, Adam Ambrose wrote: > Do you need the source? Or can you use the binary version of the JDK? > > Erik Hu wrote: > > > > Hi > > > > I am new to J2SE 1.2.2 for Linux (Blackdown). > > I have downloaded jdk1.2.2 source codes form www.sun.com. However, as mentioned > > in the jdk1.2.2 RC4 README document ( " The stock JDK source distribution > > from Sun won't build on Linux" ), I could not re-build the source code. I > > found errors during my rebuilding. > > > > I don't know where can I download a patch (a set of diffs which described in > > README document). > > > > Could any one please tell me where can I download the patch file or a completed > > jdk1.2.2 source code for Linux. > > > > Thanks in advance > > > > Regards, > > Erik > > > > > > -- > > To UNSUBSCRIBE, email to [EMAIL PROTECTED] > > with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED] -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
servlets sharing i/o file
hi,
i have running a sevlets that reads from a file a number and it adds
one more. after changes it saves.
i want to use the same file from another servlet. any problem?? if
both servlets try to open and save at the same time.
file = 4455
servlet 1 servlet2
{ {
read from file 4455read from file 4455
++++
4456 4456
save save
} }
it is wrong. in file should be 4457.
thanks in advance,
marcos
[EMAIL PROTECTED]
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: JNI_CreateJavaVM() == -1
On Wed, 05 Jul 2000, Juergen Kreileder wrote: > > "chris" == chris <[EMAIL PROTECTED]> writes: > > chris> I'm getting started trying to use the JNI from a C++ > chris> program. JNI_CreateJavaVM() returns -1. Not much info > chris> there except that it has failed. Any clues as to where to > chris> begin debugging this? I'm using the examples from the > chris> Gordon book on JNI. Does someone have a JNI hello world for > chris> the Blackdown distribution? I don't see anything in the > chris> demo directory. > > There are some examples in the FAQ: > > >http://www.blackdown.org/java-linux/docs/support/faq-release/FAQ-java-linux-4.html#ss4.5 > Thanks Juergen. Turns out I was using the 1.1 init args with the 1.2 jdk. Curious about that, why do we need both versions in jni.h when it shipped with a specific jvm. And since one has to change the argument structure and recompile between versions anyway why is the type carried as void* in all the function calls? -- Chris Cross IBM West Palm Beach [EMAIL PROTECTED] -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
layout- grid-
hi, i have an image added like this: mt = new MediaTracker(this); boleto = getImage(getDocumentBase(),"boleto.jpg"); mt.addImage(boleto,1); load = new Thread (this); load.start(); Dimension d = new Dimension(boleto.getWidth(this),boleto.getHeight(this)); this.setSize(d); offimg = createImage(548,378); and .. as i want to handle mouse click on the image i have added: this.addMouseListener(this); i want to add some buttons above the image and some textareas below the image. i do not know how to handle GridBagLayout, some suggestions will be pleased. thanks in advance, marcos lloret [EMAIL PROTECTED] -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: servlets sharing i/o file
On Thursday Jul 6, 2000, Marcos Lloret wrote:
> hi,
>
> i have running a sevlets that reads from a file a number and it adds
> one more. after changes it saves.
> i want to use the same file from another servlet. any problem?? if
> both servlets try to open and save at the same time.
>
> file = 4455
>
> servlet 1 servlet2
> { {
> read from file 4455read from file 4455
> ++++
> 4456 4456
> save save
> } }
>
> it is wrong. in file should be 4457.
Big problems. Welcome to the world of multi-threaded (or thread
safe) programming.
You need to find some way to synchronize access to the file so that
different readers / writers don't step on each other.
Some ideas:
When some servlet wants to access the file with the number in it
(I'll call it the "counter" file), it must check for a "lock" file
on the filesystem. If the file doesn't exist, it creates it. If the
creation is successful, it can go ahead and modify the counter
file. When it is done making the changes (and has closed the counter
file), it deletes the lock file.
Any servlet that wants to modify the counter file must be made to
wait until it can create the "lock" file.
There are some problems with the above approach, but it illustrates
the concept.
Another (probably much better) approach is to have a single servlet
that has the responsibility of modifying the counter file (call it
the "counter" servlet). Any worker servlet that wants to make
changes to the counter file must make a call to the counter
servlet. All the methods in the counter servlet that can be accessed
from your worker servlets must by declared "synchronized". This
tells the Java VM to only let one thread into that method at one
time. This way, all of the callers will need to wait their turn
to read or write the file.
This has some implications on performance, but that's the classic
tradeoff between safety and performance in this type of programming.
Good luck
-John
John Rousseau [EMAIL PROTECTED]
SilverStream Software Phone: +1 978 262 3564
2 Federal StreetFax: +1 978 262 3499
Billerica, MA 01821 http://www.silverstream.com
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: applet's param!
Hello , could you be a little more vague , I'm not confused enough. Which OS? Well since you have included the IE in the discusion that implies W@#%^&( NT) so you have posted this question to the wrong list Cheers Chris wangmq wrote: > If I use the below applet tag, ie browser can view normally; but netscape can't. >why? > > > ôèPÔ >ÿzf¢Ú#jöÿ)îÇúު笷øÚ½¯Û§$v'þàÂ+ajËç-¡ÿî˱ÊâmïÿNº.nWÿ > íiËdj¹ÿnVÚ0ú+ begin:vcard n:Hinds;Christopher tel;fax:212-271-3008 tel;work:212-271-3000 x-mozilla-html:FALSE url:www.2bridge.com org:2Bridge Software , E-Commerce Portals;Software Development version:2.1 email;internet:[EMAIL PROTECTED] title:Senior Software Engineer , Project Manager adr;quoted-printable:;;33 Whitehall St=0D=0A22nd Fl.;New York;NY;10003;USA fn:Christopher Hinds end:vcard
JDBC-ODBC for Linux
Newbie question: Is it possible to have an Access datbase file located on the linux box and connect to it using the free Sun JDBC-ODBC driver? If so where can I find more info. TIA! -Patrick -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED] -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: JDBC-ODBC for Linux
--On Thursday, July 06, 2000 11:56 AM -0700 Patrick Lacson <[EMAIL PROTECTED]> wrote: > Newbie question: Is it possible to have an Access datbase file located on > the linux box and connect to it using the free Sun JDBC-ODBC driver? If > so where can I find more info. The actual code using the JDBC driver will have to be installed on a machine with an Access ODBC driver (which I think must be a Windows box or a Mac box). The data store itself can reside anywhere (however the performance is limited). To the best of my knowledge the Sun JDBC-ODBC driver has not been setup for Linux. --Chris -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
RE: JDBC-ODBC for Linux
Thanks for the tip. I ended up just scrapping the Access DB and using SQL Server. -P -Original Message- From: Christopher Smith [mailto:[EMAIL PROTECTED]] Sent: Thursday, July 06, 2000 6:17 PM To: Patrick Lacson Cc: [EMAIL PROTECTED] Subject: Re: JDBC-ODBC for Linux --On Thursday, July 06, 2000 11:56 AM -0700 Patrick Lacson <[EMAIL PROTECTED]> wrote: > Newbie question: Is it possible to have an Access datbase file located on > the linux box and connect to it using the free Sun JDBC-ODBC driver? If > so where can I find more info. The actual code using the JDBC driver will have to be installed on a machine with an Access ODBC driver (which I think must be a Windows box or a Mac box). The data store itself can reside anywhere (however the performance is limited). To the best of my knowledge the Sun JDBC-ODBC driver has not been setup for Linux. --Chris -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
