Skip to content

Different Java Scanner for input of different types

Imagine the following scanario: I have a program which ask for an integer input, followed by a String input. With the aobe codes, I was not given a chance to enter the name. So normally I will declare 2 scanner objects as follows: My question is: Is it necessary to declare multiple scanner objects to accept i…

How to split a byte array around a byte sequence in Java?

How to split a byte[] around a byte sequence in Java? Something like the byte[] version of String#split(regex). Example Let’s take this byte array: [11 11 FF FF 22 22 22 FF FF 33 33 33 33] and let’s choose the delimiter to be [FF FF] Then the split will result in these three parts: [11 11] [22 22 …

Hibernate C3P0 settings performance issues

Since we have added C3P0 connection pooling to the application performance became slower. It is Oracle 10g database, Hibernate 3.1.3 and C3P0 0.9.0.4. WebSphere application server. I am very new to this things, so I don’t understand everything. Is this configuration could slow down the app performance? …

Kill process before disconnecting

I am using Jsch to tail a server-log. When I close my exec-channel and session, the “tail -f …” process still stays alive at server side. I tried to do channel.sendSignal(“KILL”) but it throws an exception: com.jcraft.jsch.JSchException: failed to send channel request how can I d…

Terminating a Java Program

I found out ways to terminate (shut-down or stop) my Java programs. I found two solutions for it. using return;When I want to quit or terminate my program execution , I add this. using System.exit() ; Sometimes I used it. I read about System.exit() from this question. So, I know a little on both them. But I a…

Setting generator to specific value

I”m converting a database and I need to set a generator to a value prior to generating new numbers. Say the generator is called gtest. I’ve tried the following: PreparedStatement nrps = csource….