java

JAVA Swing client, Data Access to Remote Database; Ibatis

I've got a Java client that needs to access a remote database. It is the goal to hide database credentials from the user and not hardcode any credentials within the code. Therefore, the database access will probably have to be on the server side. I'm restricted to use Ibatis as a data abstraction framework. Apart from that I have JBoss ...

computing performance

I need to find out the time a function takes for computing the performance of the application / function. is their any open source Java APIs for doing the same ? ...

How can I transition from Java to Clojure?

After discovering Clojure I have spent the last few days immersed in it. What project types lend themselves to Java over Clojure, vice versa, and in combination? What are examples of programs which you would have never attempted before Clojure? ...

Writing resultset to file with sorted output

I want to put "random" output from my result set (about 1.5 mil rows) in a file in a sorted manner. I know i can use sort by command in my query but that command is "expensive". Can you tell me is there any algorithm for writing result set rows in a file so the content would be sorted in the end and can i gain in performance with this? ...

How do I use oracle.jdbc.driver.OracleLog?

I am receiving an error from the Oracle JDBC driver (ojdbc14_g.jar) when trying to obtain a connection to a 10g database. The driver has an oracle.jdbc.driver.OracleLog class which could help but the Oracle documentation is unclear how best to use it. Has anyone had any success using this class? If so, some guidance on its use would be a...

Design of inheritance for Validate interfaces

I've never been so good at design because there are so many different possibilities and they all have pros and cons and I'm never sure which to go with. Anyway, here's my problem, I have a need for many different loosly related classes to have validation. However, some of these classes will need extra information to do the validation. I ...

Is there a way to simulate the C++ 'friend' concept in Java?

I would like to be able to write a Java class in one package which can access non-public methods of a class in another package without having to make it a subclass of the other class. Is this possible? ...

Java: Swing Libraries & Thread Safety

I've often heard criticism of the lack of thread safety in the Swing libraries. Yet, I am not sure as to what I would be doing in my own code with could cause issues: In what situations does the fact Swing is not thread safe come into play ? What should I actively avoid doing ? ...

How to Serialize Hibernate Collections Properly?

I'm trying to serialize objects from a database that have been retrieved with Hibernate, and I'm only interested in the objects' actual data in its entirety (cycles included). Now I've been working with XStream, which seems powerful. The problem with XStream is that it looks all too blindly on the information. It recognizes Hibernate's ...

Xml configuration versus Annotation based configuration

In a few large projects i have been working on lately it seems to become increasingly important to choose one or the other (XML or Annotation). As projects grow, consistency is very important for maintainability. My question is, what do people prefer. Do you prefer XML based or Annotation based? or Both? Everybody talks about XML conf...

How to create documented WSDL using XFire

Hi there, I use XFire to create a webservice wrapper around my application. XFire provides the webservice interface and WSDL at runtime (or creates them at compile time, don't know exactly). Many of our customers don't know webservices very well and additionally they simply don't read any external documentation like Javadoc. I know tha...

Regexp: Substituting a version number in an XML file

Ok I give up, I've been trying to write a regexp in ant to replace the version number from something that I have in a properties file. I have the following: <?xml version="1.0" encoding="UTF-8"?> <feature id="some.feature.id" label="Some test feature" version="1.0.0" provider-name="Provider">...

How to output video to a texture in Java?

I need to put video playback to my game, and the video must be in a texture so that it is played inside the game world. I am using Java (Java3D, JOGL). How can I do this? Any ideas? ...

How to determine the class of a generic type?

Hi all, I'm creating a generic class and in one of the methods I need to know the Class of the generic type currently in use. The reason is that one of the method's I call expects this as an argument. Example: public class MyGenericClass<T> { public void doSomething() { // Snip... // Call to a 3rd party lib T bean = (T)s...

How do I send a binary attachment in an email with Java using the JavaMail API?

Using JDK1.5 how does one send a binary attachemnt (such as a PDF file) easily using the JavaMail API? ...

Spring + Hibernate: how to have a configurable PK generator?

We use Spring + Hibernate for a Webapp. This Webapp will be deployed on two unrelated production sites. These two production sites will use the Webapp to generate and use Person data in parallel. What I need to do, is to make sure that the Persons generated on these two unrelated production sites all have distinct PKs, so that we can m...

Do you change the way you think when moving between Java and C#

This is a question for anyone who has the pleasure to work in both Java and C#. Do you find that you have to make a mental context switch of some kind when you move from one to the other? I'm working in both at the moment and because the syntax and libraries are so similar and yet subtly different I'm finding it frustrating when i move...

How to test whether method return type matches List<String>

What is the easiest way to test (using reflection), whether given method (i.e. java.lang.Method instance) has a return type, which can be safely casted to List<String>? Consider this snippet: public static class StringList extends ArrayList<String> {} public List<String> method1(); public ArrayList<String> method2(); public StringList...

IBM Websphere OutOfMemoryException.

Often, I found OutOfMemoryException on IBM Websphere Application Server. I think this exception occur because my application retrieve Huge data from database. So, I limit all query don't retreive data more than 1000 records and set JVM of WAS follow + Verbose garbage collection + Maximum Heap size = 1024 (RAM on my server is 16 GB and n...

Capistrano for Java?

I'm a big fan of Capistrano but I need to develop an automated deployment script for a Java-only shop. I've looked at Ant and Maven and they don't seem to be well geared towards remote administration the way Capistrano is - they seem much more focused on simply building and packaging applications. Is there a better tool out there? ...