We're having a bit of fun here at work. It all started with one of the guys setting up a Hackintosh and we were wondering whether it was faster than a Windows Box of (nearly) same specs that we have. So we decided to write a little test for it. Just a simple Prime number calculator. It's written in Java and tells us the time it takes to ...
I need to insert 20,000 rows in a single table (SQL Server 2005) using iBatis. What's the fastest way to do it ? I'm already using batch mode, but it didn't help much:
try {
sqlMap.startTransaction();
sqlMap.startBatch();
// ... execute statements in between
sqlMap.commitTransaction();
} finally {
sqlMap.endTransaction();
}
...
In Websphere when you do an LDAP query using LdapContext are the transmission of credentials encrypted?
LdapContext ctx = new InitialLdapContext (env, null);
Lets say I make an LdapContext for a web app to do some custom LDAP calls.
How do I know if my call is secure / encrypted?
...
How Can I put information in a outputstream from tapestry5 ?
I need a page when a user enters it open a dialog for save or open the file with the outputstream information.
I write the next code:
public class Index {
@Inject
private RequestGlobals requestGlobals;
@OnEvent("activate")
public void onActivate() {
try {
HttpS...
Is there any plugins for Eclipse for portlet design and deployment? I have never designed portlets so are there any good tutorials on the web as well?
...
I have this naive regex "<([\s]|[^<])+?>" (excluding the quotation marks). It seems so
straightforward but it is indeed evil when it works against the below HTML text. It sends the Java regular expression engine to an infinite loop.
I have another regex ("<.+?>"), which does somewhat the same thing, but it doesn't kill anything. Do you...
I am seeing a strange problem:
I have a linux machine, installed JDK1.6 on that machine, and some business went on, and some days later had to change the IP address of the machine. and now after some months... i am trying to get some spring application to work... and it seems the RMI Server is starting at my old ip address...
21:12...
I need to test a JDBC connection to a database. The java code to do that should be as simple as:
DriverManager.getConnection("jdbc connection URL", "username", "password");
The driver manager will lookup the appropriate the driver for the given connection URL. However I need to be able to load the JDBC driver (jar) at runtime. I.e I d...
Is there anyway to get Eclipse to automatically look for static imports? For example, now that I've finally upgraded to Junit 4, I'd like to be able to write:
assertEquals(expectedValue, actualValue);
hit ctrl-SHIFT-O and have Eclipse add:
import static org.junit.Assert.assertEquals;
Maybe I'm asking too much.
...
I was really looking at the differences between pass by value and how Java allocates objects and what java does to put objects on the stack.
Is there anyway to access objects allocated on the heap? What mechanisms does java enforce to guarantee that the right method can access the right data off the heap?
It seems like if you were cra...
Suppose that I have a Java program within an IDE (Eclipse in this case).
Suppose now that I execute the program and at some point terminate it or it ends naturally.
Is there a convenient way to determine which lines executed at least once and which ones did not (e.g., exception handling or conditions that weren't reached?)
A manual way...
I want to output a timestamp with a PST offset (e.g., 2008-11-13T13:23:30-08:00). java.util.SimpleDateFormat does not seem to output timezone offsets in the hour:minute format, it excludes the colon. Is there a simple way to get that timestamp in Java?
// I want 2008-11-13T12:23:30-08:00
String timestamp = new SimpleDateFormat("yyyy-MM-...
Can't believe I don't know the answer to this, but getting late and SO is my only hope of getting some decent sleep ;)
So far I know these are not it:
assert solver.solveArray(array3) == -1
assert solver.solveArray(array3) == (-1)
...
Hello,
I'm making a Java application with an application-logic-thread and a database-access-thread.
Both of them persist for the entire lifetime of the application. However, I need to make sure that the app thread waits until the db thread is ready (currently determined by calling dbthread.isReady()).
I wouldn't mind if app thread block...
I am writing unit tests for a class, which has a static final variable.
However, since the state of the static final var is modified in each test, I need some way to reinitialize it.
How would this be possible? Would i need to use some sort of a custom classloader?
The variable is initialized as -
static final CountdownLatch latc...
During navigation of Method class I came across the function isBridge(), javadoc of which says, that its true only if java spec declares the method as true.
Please help me understand what this is used for ? Can a custom class declare its method as a bridge if required ?
...
I have installed m2eclipse plugin from http://m2eclipse.codehaus.org/. Now I want to use that as a standalone build tool but I am unable to find the installation directory. Can anyone help me in this?
...
I'm searching for a way of developing a MethodInterceptor which prints the caller class.
Is there any way of getting the caller object into the method interceptor?
...
I've written a program that counts lines, words, and characters in a text: it does this with threads. It works great sometimes, but not so great other times. What ends up happening is the variables pointing to the number of words and characters counted sometimes come up short and sometimes don't.
It seems to me that the threads are some...
How to get the number of years between two java.util.Date?
Note: using only java.util.Date...
...