java

Large ResultSet on postgresql query

I'm running a query against a table in a postgresql database. The database is on a remote machine. The table has around 30 sub-tables using postgresql partitioning capability. The query will return a large result set, something around 1.8 million rows. In my code I use spring jdbc support, method JdbcTemplate.query, but my RowCallbackH...

Any real world experience with H2 database?

Has anybody out there got any real world experience with the H2 database? I'm interested in: performance stability bugs ...

Best language tooling

I was listening to a podcast recently (may have been SO - can't remember) when the interviewee said that one of the reasons Java was so successful and popular was the tooling. Having use of great FOSS editors such as Eclipse, NetBeans. Metrics tools such as Cobertura, Find Bugs, Build tools such as Maven and ANT.. I'd have to agree I'v...

Usefulness of ArrayList<E>.clear()?

I was looking through the Java documentation, and I came across the clear() method of ArrayLists. What's the use of this, as opposed to simply reassigning a new ArrayList object to the variable? ...

Searching a large string to see if invalid "parameter" exists

I have a large string, similar to this one: BREW pot HTCPCP/1.0 Accept-Additions: #milk;3#whiskey;splash Content-Length: 5 Content-Type: message/coffeepot I also have an array with several additions (#whiskey, #espresso, etc). What I need to do is send an error if this large string contains an addition that is NOT i...

Do I need to clean up the char* passed to NewStringUTF?

I think yes, but the top 12 examples I found all do something not illustrative like JNIEXPORT jstring JCALL Java_com_foo_dumbImpl(JNIEnv* env, jobject thisObj) { return (*env)->NewStringUTF(env, "constant string"); } so for posterity I will ask: this is bad, yes? JNIEXPORT jstring JCALL Java_com_foo_dumbImpl(JNIEnv* env, jobject t...

Why does ant compile all classes each run?

I'm more accustomed to make, so I'm confused why ant recompiles classes when the source hasn't been changed. I've read that there is a requirement to recompile in some cases where generics are used, but I'm not sure that this will be necessary for my project. Also, in the javac task, I've set includeDestClasses="true" Here's some of t...

Eclipse RCP: Suppress the context menu of the persective bar

I would like to suppress the context menu that shows when right clicking on the perspective tool bar in an rcp application. To clarify, I do want the perspective bar and shortcuts to show, but I do not want the context menu to pop up. All perspective tool bar api seems to be internal. Thanks. ...

Putting Applet on web in Java using Netbeans

When I try to put the applet online, I go to the jsp page that loads it and get Error. Click for more details. When I click for more details, I get ... Java Plug-in 1.6.0_11 Using JRE version 1.6.0_11 Java HotSpot(TM) Client VM User home directory = C:\Documents and Settings\gdf5010 c: clear console window f: finalize objects on...

What is the scope of cache flushing required by Java's synchronize keyword?

I have been researching the Java Memory Model all day today, in order to understand in detail the problems with the JMM pre-Java 5 and the changes made by JSR-133 implemented in Java 5. What I cannot seem to find a definitive answer on is the scope of cache invalidation and flushing required on a particular synchronize. Must all CPU re...

What can I do with EJB?

I'd like to test my knowledge in EJB, making an small application. Could you give me some ideas for doing with EJB? ...

Why doesn't Java have a copy constructor?

Why doesn't Java support a copy constructor like in C++? ...

What are the advantages of Blocking Queue in Java?

I am working on a project that uses a queue that keeps information about the messages that to be sent to remote hosts. In that case one thread is responsible to put the information into the queue and another thread is responsible for get the pop the information from the queue and send. In that case the 2nd thread needs to check the queue...

Closing a modal JInternalFrame

I followed approach 2 of this guide, so now I have a ModalInternalFrame that blocks input to all other frames, just as I wanted. However, I made one change from the example, and now I have two problems. The Change I removed the JOptionPane, because the whole point is to show my own pane. In order to make it close, I set closeable to t...

Authentication using URI userinfo component http://userinfo@hostname:port/path in a servlet

Hi, I need to identify users according to an URI subset. It has the following pattern http://userinfo@hostname:port/path. The java.net.URI (http://java.sun.com/j2se/1.4.2/docs/api/java/net/URI.html) implementation represents the URI. However, in the servlet i was not able to retrieve the URL/URI containing the "userinfo" URI's componen...

Python-style integer division & modulus in C

In Python and Ruby, signed integer division truncates towards negative infinity, and signed integer modulus has the same sign the second operand: >>> (-41) / 3 -14 >>> (-41) % 3 1 However, in C and Java, signed integer division truncates towards 0, and signed integer modulus has the same sign as the first operand: printf("%d\n", (-41...

Is it possible to refactor this Java code?

I have a simple code below: import java.util.ArrayList; public class BoidList extends ArrayList { synchronized public Boid GetBoid( int idx_ ) throws ArrayIndexOutOfBoundsException { if( idx_ < super.size() && idx_ >= 0 ) { return (Boid) super.get(idx_); } else { throw new ArrayIndexOutOfBou...

How do I listen for a user exit in my Eclipse plugin?

Hi all, I am writing an Eclipse plugin for a college project and need to be able to run code when the user exits and I can't find the correct Listener to enable me do this. An example of similar code is shown below where I listen for successfully completed save events and call a method when this occurs. public class ExecutionListener i...

Is there an accepted best-practice on making asynchronous HTTP requests in Android?

I've seen any number of examples and they all seem to solve this problem differently. Basically I just want the simplest way to make the request that won't lock the main thread and is cancelable. It also doesn't help that we have (at least) 2 HTTP libraries to choose from, java.net.* (such as HttpURLConnection) and org.apache.http.*. ...

Java - wait and notifyAll

What happens when you call notifyAll method on an object that is not waiting? Should there be exception or is it normal situation? ...