java

Is DBCP (Apache Commons Database Connection Pooling) still relevant?

The JDBC 3.0 spec talks about Connection (and Prepared Statement) pooling. We have several standalone Java programs (i.e. we are not using an application server) that have been using DBCP to provide connection pooling. Should we continue to use DBCP, or can we take advantage of the JDBC-provided pooling and get rid of DBCP? We are usi...

Is there a recommend way to get Spring 2.5+ to autowire Hibernate domain objects

Is there a recommend way to get Spring 2.5+ to autowire Hibernate (3.0+) domain objects. I realize that there is a way to do this using AspectJ (@Configurable), but I would like to avoid pulling in AspectJ. Some Googling found this DependencyInjectionInterceptorFactoryBean class but it seems to just live in the sandbox (and just in 2.0....

How do I place an IN parameter with a LIKE with a RowSet?

I have fighting to get a IN parameter to work inside of a LIKE statement now for hours! I am using a CachedRowSet, which I understand should follow the same rules as a PreparedStatement. Here is the basic query: CachedRowSet cache; String sql = "SELECT x " + "FROM Y " + "WHERE z LIKE '?__'" cache.setComm...

JSP template inheritance

Coming from a background in Django, I often use "template inheritance", where multiple templates inherit from a common base. Is there an easy way to do this in JSP? If not, is there an alternative to JSP that does this (besides Django on Jython that is :) base template <html> <body> {% block content %} {% endblock %} </body...

Deleting a File using J2ME throws an IOException

I am attempting to delete a file using J2ME's FileConnection.delete() method, but I an IOException is being thrown each time I call the delete() method. I have written a conditional statement to verify the existence of the file, but irregardless of that fact, an IOException is thrown. According to the FileConnection API, when delete() i...

Function to convert single objects to an array?

I wanted to write a function that would take an object and convert it to an array that contains that object as a single element. It occurred to me that I could maybe do this with generics and variable arguments to essentially do this automatically, without the need to write a function for each object type I wished to use. Will this cod...

What basic operations on a Map are permitted while iterating over it?

Say I am iterating over a Map in Java... I am unclear about what I can to that Map while in the process of iterating over it. I guess I am mostly confused by this warning in the Javadoc for the Iterator interface remove method: [...] The behavior of an iterator is unspecified if the underlying collection is modified while the iterati...

Validation in struts 2

Hi all, Please solve my following confusions about validation in Struts2 - 1) Can we do client side and server side validation through JavaScript ? 2) Can we do client side and server side validation through AJAX ? If possible then which one is beneficial for client side validation and which one for server side ? Looking for your rep...

Lazy Loading DTO fields in Spring

I have a project that is using Spring and is broken down into a couple dozen DAOs and associated DTOs. I'm using JdbcTemplate, but not much else, as it's exactly the level of abstraction I'm happy with. I'm currently performing lazy loading on my DTOs by placing some rather hairy code in their getters. Basic boilerplate logic is: 1....

Date display in different locales in Java?

In java how do I display dates in different locales (for e.g. Russian). ...

Error 1053 while trying to restart/stop Tomcat 5.0.30 (installed as a windows service)

I have Tomcat 5.0.30 installed as a Windows service. This service is starting perfectly fine. However when I try to restart or stop the service from the Windows services console, I'm getting the following error: * Could not stop Tomcat service on Local Computer. Error 1053: The service did not respond to the start or the control...

Eclipse eye for a Visual Studio guy

Hello, trying to do some Android development, which means Eclipse, however, most of my experience is Microsoft tools (e.g. Visual Studio). My java experience is mostly either Blackberry dev in the JDE and some miscellaneous stuff back in the Java 1.0 days. My question is this. In VS200x, there is a .sln (solution), .csproj (project)...

What advantages have a commercial Java profiler over the free ones, e.g. the one in Netbeans?

Occasionally I have to do some profiling work on Java code, and I would like to know why I should have my boss investigate in a commercial profiler as opposed to just use the one in Netbeans or JConsole? What would the killer features be that would warrant the investment? ...

run a batch file that is present in remote machine

Hi, import java.io.*; class Visuals{ public static void main(String arg[]){ try{ String command = "cmd /C start C:/Visuals/VisualTimeSeries081308Ratnesh/VisualTimeSeries081308Ratnesh/bat/demo/StartVisTsDataCenterMySql-log.bat"; Runtime rt = Runtime.getRuntime(); Process pr = rt.exec(command); //pr.destroy();...

run a web project developed in Java run on both windows and Linux platform

Hi, I have a web project developed in java. I am using the Windows platform and accessing the project from the Windows machine itself. How can I make the project run on a Linux machine? I am using jboss server and deploying the project. Regards ...

Can a layout manager spawn several JPanels?

I have to build a rather large form with many controls. The controls are divided in basic controls/settings and extended controls/settings. The user can decide if he wants to see only the basic or both basic and extended controls. I've dropped all extended controls onto their own JPanel so that I can easily switch between the two views ...

How can flash pass J2EE authentication - it can't send a cookie containing jsessionid

We have a web page of a J2EE application, in which the user signs-in to the application. It contains a flash widget that needs to call services in the server, using the session that the user created. The web page passes the jsessionid to the flash widget, in order for the flash to use it to pass the authentication. However, the flash p...

Counting lines, words, characters and top ten words?

Hi I'm pretty new to Stack Overflow so I hope that I'm doing this correctly and that someone out there has the answer I need. I'm currently coding a program in Java with Eclipse IDE an my question is this: I need a snippet of code that does the following It's supposed to get a .TXT file containing text and from that .TXT file count t...

Why Java, C# and C++ don't have ranges?

Ada, Pascal and many other languages support ranges, a way to subtype integers. A range is a signed integer value which ranges from a value (first) to another (last). It's easy to implement a class that does the same in OOP but I think that supporting the feature natively could let the compiler to do additional static checks. I know tha...

Is it safe to construct Swing/AWT widgets NOT on the Event Dispatch Thread?

I've been integrating the Substance look and feel into my application and ran into several problems regarding it's internal EDT (Event Dispatch Thread) checking routines. Substance absolutely refuses to construct UI classes outside of the EDT. I've done plenty of Swing/AWT and I know most of the rules regarding the EDT. I use SwingWorker...