java

Detecting if a method is declared in an interface in Java

Help me make this method more solid: /** * Check if the method is declared in the interface. * Assumes the method was obtained from a concrete class that * implements the interface, and return true if the method overrides * a method from the interface. */ public static boolean isDeclaredInInterface(Method method, Class<?> i...

Unsupported SQL Type 1111 when passing String to a VARCHAR field

I have been smashing my head against this for a while now. I am using iBatis with my JAVA code to run Stored Proc residing in Sybase DB. Stored procedure is expecting some parameters. few of them are declared as VARCHAR (6) So in my iBatis mapping i did the following for those parameters. <parameter property="searchUserId" jdbcTyp...

What ways exist to distribute asynchronous batch tasks?

I am currently investigating what Java compatible solutions exist to address my requirements as follows: Timer based / Schedulable tasks to batch process Distributed, and by that providing the ability to scale horizontally Resilience, no SPFs please The nature of these tasks (heavy XML generation, and the delivery to web based recei...

How to revise java?

Ok so this isn't 100% programming question, for which I'm really sorry, but still this is the best place I know to ask it. In ~2weeks time I'll have a job interview, first they'll make me take a test from Java and I was wondering what's the best way to prepare for it? I bet it will be something similar to SCJP (but probably much easier)...

Importing a (mysql) database dump programmatically through Java

Hi All, How can I import a mysql database dump file (contains insert and create table statements) programmatically through a java program. I need this as the setup phase of a unit test. Unfortunately this doesn't work: Connection conn = dbConnectionSource.getConnection(); Statement stmt = conn.createStatement(); stmt.execute(FileUtil...

At what point is it worth reusing arrays in Java?

How big does a buffer need to be in Java before it's worth reusing? Or, put another way: I can repeatedly allocate, use, and discard byte[] objects OR run a pool to keep and reuse them. I might allocate a lot of small buffers that get discarded often, or a few big ones that's don't. At what size is is cheaper to pool them than to real...

What's the easiest way to persist java objects?

Right now I have java program whose classes are currently POJOs and stored in volatile memory. These need to be persisted. As I understand it two popular choices are JDO and the Java Persistence API. For someone who know little about SQL, Torque, etc, which is the easiest way to add persistence to my program's data? ...

Generate list of classes in order of dependency

Hi all, I'm doing a build script for a Java application to run inside the Oracle JVM. In order to import the 50-odd classes, it appears I need to bring them in in order so any dependencies are present before compilation. For each class, I'm running 'create or replace and compile java source {className} as {classPath}' for each file. D...

Can a jax-ws web service use an rpc type call and receive raw xml?

Hello. I have a web service that I've been working on and it's wokrring fine so far by creating a port in the client and then calling a method on the port. However, I've just been told that a couple of the clients who will be using the web service plan on sending it raw xml based based off of the schemas used by the web service and I was...

Best Practices for Code Formatting on Large Projects

I maintain the build for a large J2EE/Maven/Hudson/Perforce project with about 20 developers spread across the world. The solution in-place for code formatting is to format the codebase using jalopy when the developer runs the build, thereby ensuring any code which has not been formatted gets formatted prior to check-in. There main pro...

How does keytool protect keys?

When you are building a key store with the Java Keytool utility, how are the keys protected? I've read through the documentation, and I realize that each private key has a key password, and then the store has a store password. But what mechanism is used to protect the data? Is it an encryption cipher? If so, what is the algorithm? I...

Pattern Matching framework?

I will be tackling a Java (GWT) project soon (related question). Maybe I am trying to stretch things here but I was wondering if there is any "pattern matching framework" (don't really know if there is a term for this) written in Java? (maybe it is my prolonged exposure to Erlang that twists my thoughts around patterns all the time :-) ...

Is Javaspaces supported on GWT?

Following a suggestion on a related post (see here), I was wondering if Javaspaces technology is supported on GWT? ...

How to send an Object from one computer to another?

I know that the Java can use the Socket Programming to send an Object. Apart from socket programming, anything other way to do it? ...

Good tutorials on Bitwise operations in Java

Can anyone please point me to good online tutorials on Bitwise Operations (preferably in Java)? Before anyone write LMGTFY, I've already Googled it but couldn't find one with good examples. Java's own tutorial is also not that extensive and doesn't clearly explain what is going under the hood. I'm a visual learner; so, if there are any r...

Is Web Service suitable for ETL purpose?

Hi, My company is considering using web service as mean of ETL process. However I don't think web service fit into this purpose, for several reasons: 1. web service could possibly consume a lot of memory when generating large xml. 2. xml is a bloated format. 3. possibly time-out if the server takes huge amount of time to generate data 4...

GWT: get locale information from server side ?

I use GWT along with Spring/Hibernate/AOP. I use an Aspect to send notification emails. In one of my Aspect, I want to get the current locale from GWT,so that I can send the localized email to the user. Is there a way to access GWT Locale data from the client side? Thanks ...

Java NoClassDefFoundError when the jar clearly has it

I have a simple class that imports another class from another jar. Everything compiles great, but trying to run it... $ jar tvf ../../pig-2.1.jar | grep TupleFact 1641 Mon Feb 02 17:56:32 UTC 2009 org/apache/pig/data/DefaultTupleFactory.class 2289 Mon Feb 02 17:56:30 UTC 2009 org/apache/pig/data/TupleFactory.class $ javac ../src/Conver...

[java] String can't change. But int, char can change.

I've read that in Java an object of type String can't change. But int and char variables can. Why is it? Can you give me an example? Thank you. (I am a newer -_- ) ...

Adding new terms in the Gosen Dictionary

Good day, How do you add new terms in the Gosen's Dictionary? Thanks, Franz ...