java

jdbctemplate, jpatemplate

in my dao, in each method, when i call jdbctemplate, i should call with new jdbctemplate(). right? or get one static instant of jdbctemplate and reuse ? how about jpatemplate? ...

What Are the Benefits of Struts

I recently added Struts 1.3 to my application on Tomcat. Here are my observations, MVC. Servlet/JSP does this fine for me, where JSP is the view and servlet is the controller. I don't see any benefit to get the mapping from an XML file since our mapping is very static. Action Form. I can see some benefits of action form but not huge. T...

How to identify the OS name and version in Client machine using java?

<% System.getProperty("os.name") %> can be used to identify the OS name running in the server machine. But how can i identify the OS information in the client machine using java in a web application? ...

Exception Vs Assertion

What is difference between java Exception handling and assert any condition? its know that assert is of two type.but when should we use assert keyword? ...

Java SplashScreen

I'm using NetBeans 6.1 as my primary IDE, in there I can't run this splash screen example which have given by the Sun (It throws an nullpointerExeption). But I can run this on command line using this arguments. java -splash:filename.gif SplashDemo I dont know how to inject command line arguments in NetBeans. Please someone help. impor...

Help in using shape drawable as my background xml

I really appreciate if someone can help me with using how to use shape drawable as my background xml for my view. This is what I tried: But I never get the color. Android always gives me black text on white background, regardless what color attribute I put. <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.and...

Building a plugin with two source folders fails

I have an Eclipse Plug-in that contains two source folders: src/ src-gen/ The reason is that, as the name implies, the second folder is filled with the results of code generation. However, when I try an Eclipse PDE build, or even a single export of the plugin, the code in src/ that refers to generated classes will not compile. It s...

Hibernate WrongClassException / Sets / Discriminators?

Hi, The problem looks like this: A Product table. 3 joined-subclasses: DVD, CD, Book. A Role table (composite id: NAME, ROLE, PRODUCT), and subclasses by discriminator column ROLE: actor, director, artist, author, etc.. which are mapped to Actor, Director, Artist, Author java classes; (pretty usual I guess) ... A Book has authors, a C...

When to use JAF activation

Hi I wonder if I should use it, in this example. I'm reading files, and I need to store one parameter with that file. According to this parameter I'm bundling files together and sending them over the wire. I came accross jaf activation framework, and I'm not sure if it is appropriate to use it in such simple example.(store 'file' int...

template method pattern

May i know how to create childClass if my childClass method getInfoFromDB() and saveToDB() need to do different logic? public abstract class BaseClass { public abstract Object doTransaction(); public Object executeTrans() { //do something tx.begin(); this.doTransaction(); tx....

Wrapping exceptions thrown in super/this constructor calls into other exceptions

I want the api of my module to only throw MyPackageSpecificException whenever anything goes wrong and the module unable to perform its task. (The original exception will be given as the cause of the MyPackageSpecificException). Now, for one constructor I needed an URL as a parameter to locate a resource. I would also like to make an alt...

Invoking Java code across Application Server cluster nodes

Let's say I have a Java webapp deployed on some Application Server with clustering across a few nodes. In the webapp, we maintain a cache of some values retrieved from the database, stored in-memory as static variables. Whenever a user performs an update in a particular screen, we clear the cache so that the cached values will be retrie...

In jBpm, how to get all transitions that has been taken in a flow/process?

Is it possible in jboss jBpm to fetch all transitions that has been taken during one process execution? The use case is: We would like to now all nodes, tasknodes, ... that 'users' has been through and which transition they took. This to show a list of task instances that have been finished previously from the current active token/n...

Java Swing : changing JTree selection while editingstopCellEditing() : how to get stopCellEditing() called before TreeListeners:valueChanged?

Hi, regarding to earlier question How to stop editing with DefaultCellEditor when a separate JBtton is pressed and Sun Bug 4724980: JTable: Add API to control what happens to edits when table loses focus.: With jtable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); i get my CellEditor to stop editing when table loses ...

Java generics compiler error

Hi, When doing some not really fancy things with Java, I came over an error with generics that I was not able to understand why it doesn't work. The code is: package test; import java.util.*; public class TestClass { public static class A extends C{} public static class B extends C{} public static class C{} public static class ...

JDBC: How can I query by time in Oracle?

I have this JDBC SQL query: select * from table where TX_DATE = {d '2009-01-05'} and TX_TIME = {t '15:23:39'} This returns some rows. Note that, since Oracle has no TIME type, both columns are of type DATE. But it fails when I use JDBC parameters: select * from table where TX_DATE = ? and TX_TIME = ? where the first parameter is n...

How to consume a webservice from an EJB

I am currently trying to wrap my mind around Java EE 5. What I'd like to do is create a sample application that offers a simple stateless EJB (e. g. a simple calulator with an add() method) expose this add method as a webservice consume this webservice from another EJB The first two steps are easy and I can deploy and test this bean ...

how to create daemon thread?

Can a java programmer can create daemon threads manually? How is it? ...

How can I add meta-data to recorded flv-files in red5?

Hello! I wonder how to you can add meta-data to flv-files you recorded by red5... mine just have something like this: 0.000 | FLV::Event tag | event : onMetaData | audiocodecid : -1 | canSeekToEnd : true | videocodecid : -1 | duration : 0 ...

GWT, Google App Engine, TimerTask or Thread in ServiceImpl throw exception.

I am using GWT and Google App Engine. I have array of records and I want to update them every 30 mins. In the ServiceImpl I have the fallowing code : new Timer().schedule(new TimerTask(){ @Override public void run() { try { Thread.sleep(30000); } catch (InterruptedException e) { e.printStackTrace(); } res...