java

Problem connecting to a remote database using hibernate

I'm trying to connect to a remote database (hosted on Netfirms www.netfirms.ca if anyone is curious) using hibernate. My mapping file is as follows: <hibernate-configuration> <session-factory> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <property name="hibernate.connection.url">jdbc:...

How does Java's serialization work and when it should be used instead of some other persistence technique?

I've been lately trying to learn more and generally test Java's serialization for both work and personal projects and I must say that the more I know about it, the less I like it. This may be caused by misinformation though so that's why I'm asking these two things from you all: 1: On byte level, how does serialization know how to match...

GroovyScriptEngine locating resources in a web container

I am looking at using groovy scripts in an existing web application and am busy setting up and configuring the GroovyScriptEngine. What are the "best practices" for managing the scripts in the container ? Should I store them in a database and then serve them up to the engine via urls ? I could store them in the file system on the ser...

What (not) to declare when implementing an interface with an abstract class?

I have an interface A, for which I have to supply a few different implementations. However, those implementations share some helper methods, so I moved those methods to an abstract base class. Interface A { void doX(); } abstract Class B implements A { protected void commonY() { // ... } @Override public abstract void doX(); } ...

how to make a thread wait until a file is created in java

Hi All, i have a thread in java & i need this thread to wait until a file is exist or created. i write the following code: while(!receivedDataFile.isFileExists("receiveddata.txt")) { try { Thead.sleep(1000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStac...

How to use enums with JPA

I have an existing database of a film rental system. Each film has a has a rating attribute. In SQL they used a constraint to limit the allowed values of this attribute. CONSTRAINT film_rating_check CHECK ((((((((rating)::text = ''::text) OR ((rating)::text = 'G'::text)) OR ((rating)::text = 'PG'::text)) OR ...

Getting the output of a Thread

What do you think is the best way for obtaining the results of the work of a thread? Imagine a Thread wich does some calculations, how do you warn the main program the calculations are done? You could poll every X milliseconds for some public variable called "job finished" or something by the way, but then you'll receive the results lat...

How can I set globals to JSLint to ignore for a whole set of files?

I'd like to run JSLint4Java as part of my build process. I have about 1000 JS files in a library, and don't really want to add a /*globals foo, bar, baz */ header to each of them -- especially since many of them are from an external library (Dojo). If I don't add the header, though, JSLint complains about the same five globals on ne...

Whats the best way to update a single record via SQL and obtain the id of the record that was updated? (Java/MSSQL)

I know I can update a single record like this - but then how to I get access to the id of the record that was updated? (I'm using MSSQL so I can't use Oracles RowId) update myTable set myCol = 'foo' where itemId in (select top 1 itemId from myTable ) If I was peforming an Insert I could use getGeneratedKeys to get the id field value,...

static concepts

class Trial { static int i; int getI() { return i;} void setI(int value) { i = value;} } public class ttest { public static void main(String args[]) { Trial t1 = new Trial(); t1.setI(10); System.out.println(t1.getI()); Trial t2 = new Trial(); t2.setI(100); ...

Java EBNF?

Does anyone know of an accurate source for an (E)BNF for the Java language? Preferably, it would be from an authorative source, e.g. Sun. Thanks. ...

When to catch java.lang.Error?

In what situations should one catch java.lang.Error on an application? ...

How to use MigLayout?

Hi folks, I read some information about Java layout managers and the recommendation was MigLayout. My problem is, that I didn't found any tutorial or easy step-by-step documentation. So I want to know how this all works, but I don't know how. Hope, it's not to trivial. Thanks in advance, guerda ...

Is there any library/framework for undo/redo changes of rows in database ?

May be my title is not clear. I am looking for some kind of version control on database tables, like subversion does on files, like wiki does. I want to trace the changes log. I want to extract and run the diff in reverse. (undo like a "svn merge -r 101:100"). I may need a indexed search on the history. I've read the "Design Pattern fo...

tomcat application missing displayname

I have a little project with some jsp deployed on an Tomcat 5.5. Recently the Servlets which are also deployed with the jsp files (one war archive) stopped working. I also checked out a previous version from my svn which should work. What I noticed that the displayname (I use a german version of Tomcat , so I guess that is how I would tr...

Future.get() and InterruptedException Asynchronous threading

Im using asynchronous threading in my application WITH httpClient. I make a call using the Future Api like so mStrResults = (String) rssFuture.get(); this call attempts to retrieve an html string returned from my Callable httpClient call() method. What i want to do however is ensure that the get method does not wait too long while ...

Does a truststore need the sub-ca certificate?

I'm trying to setup a hierarchical PKI. Can I create a truststore containing only the root ca certificate, and will that mean my application trusts certificates signed by a sub-ca certificate which is in turn signed by the root ca? As an aside, it seems that you must provide an entire certificate chain, including the root ca certificate...

Tail calling in Java and C#?

I was reading about Clojure and found a discussion about Java not supporting tail calls, in the current version, and that people were throwing exceptions to simulate tail calling in the JVM, anyways it sounds like people are doing some crazy stuff out there. So this got me wondering about C#'s tail calling, same issues? ...

Warning Symbol Unsigned Java Applet

In the recent update of java (6.10) http://java.sun.com/javase/6/webnotes/6u10.htmllink text the way that unsigned applets was changed. A warning is now displayed. Is it possible to turn this off without signing your applet? ...

Facial recognition/merging software

Can anyone point me in the right direction of some facial recognition libraries & algorithms ? I've tried searching/googling but i mostly find thesises and very little real software. ...