java

Store String Array in MySql through java?

I have a String Array in a java program. I am using jdbc driver to store data in MySql. There is a reference variable "pstmt" that refers to a prepared statement now I want to call the following method: String [] items = {pen, ball, speaker, mic}; pstmt.setArray(1, ....); where "items" refer to String array but the method setArray...

JAXP Source and Result implementations for POJOs

Is anyone aware of implementations of the standard javax.xml.transform.Source and javax.xml.transform.Result which operate on underlying POJOs? In other words, I want to use XSLT to transform one java object graph into another. I am currently using xstream to render the POJOs to a W3C DOM, and then using DomSource and DomResult to pass...

Where Java applets game portals?

I have started making some small Java games that run in a browser and have found a couple of game portals where I can host then (GameJolt.com, JavaGameTomb.com and Games4j.com). Most of the other portals I find either only allow Flash or offer the games for download. Apart from those above, what other portals exist that allow hosting ap...

j2me networking

I am producing a basic j2me application that collects gps information and then sends it out over a wireless network. It seems like I need a thread to read GPS and a thread to send the data over the network. This seems like a producer/consumer pattern with some sort of queuing mechanism on teh consumer side that will allow the data to...

Roles in Java Google App Engine

Does anyone have any recommendations for me on how to manage user roles on the Java version of Google App Engine? ...

Using a schema to sort an XML document

Say I have an XML document (represented as text, a W3C DOM, whatever), and also an XML Schema. The XML document has all the right elements as defined by the schema, but in the wrong order. How do I use the schema to "re-order" the elements in the document to conform to the ordering defined by the schema? I know that this should be poss...

JSTL c:import and x:parse inside of x:forEach

I am trying to use the c:import and x:parse tags within an x:forEach. Is this possible? If not, what is another way to import multiple xml sources depending on parsed data from another xml source? <x:forEach select="$sitemap/pages/page" varStatus="status"> <x:set var="location_id" select="@id"/> <c:import url="xml/pages/page${...

JBoss Class cast exception while accessing EJB3

Hi Java Gurus, I am having a weird problem here with EJB3. Deployed and EJB3 and am trying to access the business method from the deployed instance. I get the following error when the lookup is executed: UserAuthenticationRemote is the remote i/face UserAuthenticationBean is the Bean Code (which fails): UserAuthenticationRemote rem...

How to find potential numeric overflows in Java code, using Eclipse?

Is there a way to find potential numeric overflows in Java code, using the Eclipse IDE? For example... long aLong = X * Y * Z; ... where X, Y, and Z are ints and the result may overflow Integer.MAX_VALUE. (Note that, perhaps counter-intuitively, if the result in this example overflows Integer.MAX_VALUE, aLong will be assigned the erro...

Where can I find the source code for Java's HttpURLConnection.getOutputStream()

Where can I find the actual code (be it java or native) that's executed by: new URL("http://google.com").openConnection().getOutputStream() Bonus: how I can debug it from IntelliJ IDEA ? ...

Hour difference between Linux and Windows from Java date.getHour().

I have some java code that parses a string and creates a Date object. On Linux, everything works fine, but on Windows it continuously starts at 19:00:00 rather than 00:00:00. Here is the code: if(currTask != null) { if((m = p0.matcher(currTask)).matches()) { date = new Date(Long.valueOf(m.group(2)) - Long.valueOf(m.group(1))); ...

Differing behaviour between Java 5 & 6 when overloading generic methods

I've run into an issue in Java's Generics in which the same code will compile and work fine in Java 6, but will fail to compile because of the same erasure in Java 5. I have a file TestErasure.java that has an overloaded method, called "method": import java.util.ArrayList; import java.util.List; public class TestErasure { public stati...

XmlPullParser read InputSource

I know how to create InputSource out of Reader but how to go the other way? I'm capturing org.xml.sax.InputSource and now want to feed it into org.xmlpull.v1.XmlPullParser. That one has few setInput methods but these only accept Reader or InputStream as an argument. What would be the best way to convert InputSource into one of these? ...

specifying ThreadPoolExecutor problem

Is there any way to create Executor that will have always at least 5 threads, and maximum of 20 threads, and unbounded queue for tasks (meaning no task is rejected) I tried new ThreadPoolExecutor(5, 20, 60L, TimeUnit.SECONDS, queue) with all possibilities that I thought of for queue: new LinkedBlockingQueue() // never runs more than 5 ...

spring enabled web application

Hello gud fellas in my quest of learning spring, i created a web application with netbeans 6.7 in windows xp sp2.i've noticed some and have few question about that. 1 my applicationContext.xml config file is in WEB-INF and my test class cannot find it.i had a copy of it in source package under default package and i can be found.Isn't WE...

multiple JFrames from JAR

I have a Java application that launches multiple windows (JFrames). It works fine when I'm running it from the command line. But after packaging the app in a JAR and running it from the JAR, not all of the windows open. Does anyone know why this could be happening? Is there something about JAR files that prevent opening multiple windows...

Use of hasNextLine in Java, won't read NextLine after NextInt

Hey guys and gals, I am trying to get this to work System.out.println("Please enter what SOCKET NUMBER you" + "wish to connect to"); int sockname = Integer.parseInt(inFromUser.nextLine()); System.out.println("Please enter what HOSTNAME you" + "wish to connect to"); String hostname = inFromUser.nextLine(); Th...

Is it possible to force a packet to be fragmented in Java?

Hi, I have a bug which is caused by fragmented packets. I would like test this bug by creating a fragmented packet in the test and sending it to the software containing the bug. How would I go about doing this? Any guidance or alternative approaches appreciated, thanks. ...

Workaround for Java Collections wrappers breaking reflection

Today, I discovered that using Collections.synchronizedXXX doesn't play well with reflection. Here's a simple example: import java.util.ArrayList; import java.util.Collections; import java.util.List; public class Weird{ public static void main(String[] args) { List<String> list = new ArrayList<String>(); list.add("Hello Worl...

Java Hashmap Iteration: Look at two values at once?

I have this loop: for (Map.Entry<Integer, String> entry: collection.entrySet()) { } I'd like to compare entry and the next one after that. How would I do it? ...