I have a webservice that does multiple small calculations before returning the result. I want to use the ExecutorService provided by Executors.newFixedThreadPool() as a way to implement the Master - Worker pattern (ie. call invokeAll and let the thread wait for all results to finish). Ideally all webservice threads use the same executor ...
While writing a utility script to insert images into a database I wondered if there were a groovier way of doing it. In the end settled for something along the lines of this:
def sql = Sql.newInstance(...)
// ...
Connection conn = sql.getConnection()
PreparedStatement stmt.prepareStatment(...)
stmt.setBinary(...)
stmt.executeUpate()...
Can anyone point me out, how can I parse/evaluate HQL and get map where key is table alias and value - full qualified class name.
E.g. for HQL
SELECT a.id from Foo a INNER JOIN a.test b
I wish to have pairs:
a, package1.Foo
b. package2.TestClassName
It's relatively easy to do for result set
HQLQueryPlan hqlPlan = ((SessionFac...
I wander if with a simple Map implementation for plain records its enough.
I want to do it similar to Ror. When you add a field to de table in the database automatically you have access to the field in the Dto.
I don't want to add a field and then have to add the same field to de DTO declaration. It isn't DRY.
...
A custom HTTP header is being passed to a Servlet application for authentication purposes. The header value must be able to contain accents and other non-ASCII characters, so must be in a certain encoding (ideally UTF-8).
I am provided with this piece of Java code by the developers who control the authentication environment:
String f...
I am running JVM 1.5.0 (Mac OS X Default), and I am monitoring my Java program in the Activity Monitor. I have the following:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Date;
public class MemoryTest {
public static void memoryUsage() {
Sys...
Hello
I am going to make cycle of few meetings of our company dev team, which have 6 people. I want that one can show others some technology feature and how to write in it. Trainings will be in Java Enterprise technology on Eclipse IDE.
It is good idea that everyone share one HelloWorld application throug svn? The leading programmer ca...
What is your favourite Java orientated website? Can be forum, news, podcast or any type of site as long as it is about the Java programming language. All flavours of Java should be considered; SE, EE and ME.
...
Possible Duplicates:
Should I learn C# or Java?
Should freshers learn Java or C++?
I have an option of selecting Java or .NET as my language.
Which one is the best to choose? In which can I see a brighter future?
...
I'm trying to display the contents of an ordered array in something like a JTextField.
for (int i=0; i<array.length; i++) {
this.textField.setText(array[i]);
}
This won't work for two reasons. The first minor reason: if the array length is 4 then jtextfield is getting it's value reset 4 times rather than appending each element ont...
Hi sometimes i encoutner this error after restarsting sun application server 8.2 domain anyone have any idea what could be the reason?
javax.servlet.ServletException at
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:255) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:860) at
sun.reflect.GeneratedMe...
I have a java file TestThis.java like following:
class A
{
public void foo()
{
System.out.println("Executing foo");
}
}
class B
{
public void bar()
{
System.out.println("Executing bar");
}
}
The above code file is compiling fine without any warnings/errors. My question is that is there any way ...
I have a project built and packaged with a specific version of jsp-apiand servlet-api jar files. Now I want these jars to be loaded when deploying the web project on any application server for example tomcat, WAS, Weblogic etc.
The behaviour I have seen on tomcat is that it gives messages that the packaged version of these apis are not ...
Hello,
I have a Jar file, which contains other nested Jars. When I invoke the new JarFile() constructor on this file, I get an exception which says "java.util.zip.ZipException: error in opening zip file". When I manually unzip the contents of this Jar file and zip it up again, it works fine. Also, please note that this exception is seen...
I want to develop Java apps, real quick, what IDE should I choose?
...
I'm using Java 1.5 and I'd like to launch the associated application to open the file. I know that Java 1.6 introduced the Desktop API, but I need a solution for Java 1.5.
So far I found a way to do it in Windows:
Runtime.getRuntime().exec(new String[]{ "rundll32",
"url.dll,FileProtocolHandler", fileName });
...
If I'm using Long uuid = UUID.randomUUID().getMostSignificantBits() how likely is it to get a collision. It cuts of the least significant bits, so there is a possibility that you run into a collision, right?
...
Here is what I have:
JAVA_HOME=C:\Software\Java\jdk1.5.0_12 (points to JDK 5.0)
In Eclipse "Installed Runtimes" I have:
jre 1.5.0_12 (points to JRE 5.0)
jre 1.6.0_3 (points to JRE 6.0) (this one is default)
I do not have "javac" on my PATH (i.e. I cannot run javac -version from command line if I am not in JDK/bin).
My project is set ...
I loved this question/answers:
http://stackoverflow.com/questions/144568/learn-c-from-open-source-code
Would love all those great answers/links with the Java language instead!
...
I'm wanting to write a method that I can use to initialise a Map. First cut:
Map map(Object ... o) {for (int i = 0; i < o.length; i+=2){result.put(o[i], o[i+1])}}
Simple, but not type-safe. Using generics, maybe something like:
<TKey, TValue> HashMap<TKey, TValue> map(TKey ... keys, TValue ... values)
but that syntax isn't support...