java

Setting and updating connection pool (OracleConnectionPoolDataSource) properties for best performance

In a Java web application I am working on, we are using OracleConnectionPoolDataSource for a database connection pool functionality. Each getConnection call includes the user's Oracle ID and password. So each user in a sense ends up with their own database connection pool. Currently we are using the default values for most properties. T...

AtomicInteger lazySet and set

May I know what is the difference among lazySet and set method for AtomicInteger. javadoc doesn't talk much about lazySet : Eventually sets to the given value. It seems that AtomicInteger will not immediately be set to the desired value, but it will be scheduled to be set in some time. But, what is the practical use of this method? Any...

Java JDBC ignores setFetchSize ?

Hi, I'm using the following code st = connection.createStatement( ResultSet.CONCUR_READ_ONLY, ResultSet.FETCH_FORWARD, ResultSet.TYPE_FORWARD_ONLY ); st.setFetchSize(1000); System.out.println("start query "); rs = st.executeQuery(queryString); System.out.println("done query"); The query return a lot of (800k...

Is there a remote profiler for Java? (that uses JMX preferably)

I am trying to pin down a memory leak problem for my standalone Java program that runs on unix. I have the port and params setup such that I can connect to it using JMX with JConsole or VisualVM already. Those help a little but unfortunately it doesn't tell you where the memory has gone, it only tells you how much memory is used. I'm l...

Modernize Legacy Cobol

I am constantly reading about how much Cobol code is still in production. And the main reason that it hasn't been updated into am more modern language is that it would take too long/cost too much. My question is: If there was a tool that converted Cobol to, say, Java, would any organizations find it useful? Or would they rather continu...

How to un-link a JSlider's progress indicator from its thumb?

I'm using a JSlider to show progress in my application, so that it updates as a certain process computes. I want a user to be able to drag the thumb backwards to a tick mark in the past, but when this happens, I want the progress indicator to remain at its current position. // A dismal attempt at drawing the situation Progress: ------...

How to extract data from a SOAP response in Java?

Hello, I have a client set up to send a request to the National Weather Service SOAP server. I am receiving the response that I expect, but I am unsure as to the best way to extract the data from it that I need. For example, there is a lot of extra data in the XML (in the SOAPBody), but I only want to grab the data for the parameters t...

Human readable and parsable date format in Java.

I want to save a Date object to a readable string (for example 22/10/2009 21:13:14) that is also parsable back to a Date object. I have tried many things and the best I could find was to use DateFormater for parsing and formating but it has a setback. When you format a date you lose seconds information. I tried to find if there is an op...

Designing Constructors for Testability

I'm working with some existing code, trying to add to it and increase the unit tests for it. But running into some problems with getting the code testable. Original Constructor: public Info() throws Exception { _ServiceProperties = new ServiceProperties(); _SshProperties = new SshProperties(); } I'm aware that this is bad, and ob...

FutureTask that implements Callable

I really want to create a subclass of FutureTask that has a default no-arg constructor. In particular, I want my subclass to implement the Callable interface and use itself as the callable. This way, users of MyFutureTask can just subclass MyFutureTask instead of having to implement their own callable and pass it to an instance of Futu...

Spring - Weird Error in Bean Creation

Any idea why I am getting this exception? Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myService' defined in class path resource [context.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type...

Is there a way to identify a specific firing instance of a CronTrigger ahead of time?

Say I want to add a note to a specific future firing of a CronTrigger in Quartz. Is it possible to identify a specific future firing in such a way that I can give other objects a reference to it? ...

JPA: How do I synchronize the persistence context with the result of the bulk update or delete?

Hi all, There's a statement in the ejb-3_0-fr-spec-persistence.pdf which reads The persistence context is not synchronized with the result of the bulk update or delete So if I do a query.executeUpdate which deletes rows from a table. Those same rows still exist in another entities one to many collection. When I restart the applicatio...

Java JTree valueChanged Event before MouseEvent

Here's the situation, I have a jFrame with a tabbed pane and within the tabs I have a couple of jTables and a jTree. I want to be able to chain the selections between the tables and the tree based on whether a user uses a ctrl/shift + click versus a regular click. (If you hold ctrl and click in the first table/tree, it adds to the over...

Execute SQL on CSV files via JDBC

Dear all, I need to apply an SQL query to CSV files (comma-separated text files). My SQL is predefined from another tool, and is not eligible to change. It may contain embedded selects and table aliases in the FROM part. For my task I have found two open-source (this is a project requirement) libraries that provide JDBC drivers: CsvJ...

mvn exec:java on aggregate pom

Hi. Does anyone know whether it is possible to run mvn exec:java on mvn aggregate POM? Currently I get: 2009-09-24 02:24:14.404 :bash: karolrvn@karolrvn-laptop : ~/adfadf/programming/verknowsys/codadris/ide_projects $ mvn exec:java -e -Dexec.mainClass=codadris.coviob2.App_Coviob2 + Error stacktraces are turned on. [INFO] Scanning for...

How can I know all the tuesdays of a given month?

For instance in Sept I would need: 1,8,15,22 and 29 Thanks ...

How does one autohide a GWT MenuBar submenu?

We have recently attached a GWT MenuBar to a part of our application for, well, menu purposes. Basically I want the sub menus to open when you mouse over the top level menu, which is easy enough to do: menubar.setAutoOpen(true); I would also like to have the sub menu automatically hide when the user's mouse leaves the sub menu. Ideal...

Java ResultSet how to getTimeStamp in UTC

The database has data in UTC and when I try to get data java.util.Calendar cal = Calendar.getInstance(); cal.setTimeZone(TimeZone.getTimeZone("UTC")); java.sql.Timestamp ts = resultSet.getTimestamp(PUBLISH_TIME); cal.setTime(ts); Is there anything wrong with this? ...

Looking for an efficient way to find a sorted order from 2 lists

I have 2 set of unsorted integers: set A and set B. But we don't know how many items are there in setB in advance. I need to : while setA and setB are not empty: pop the smallest no from setA move an int from setB to setA What is the most efficient way to do that in Java? I am thinking create an ArrayList for setA and Link...