java

In managed code, how do I achieve good locality of reference?

Since RAM seems to be the new disk, and since that statement also means that access to memory is now considered slow similarly to how disk access has always been, I do want to maximize locality of reference in memory for high performance applications. For example, in a sorted index, I want adjacent values to be close (unlike say, in a ha...

Database Connection Always disconnect when Developing on same PC as DB

I am developing a JSP application and I used Oracle Express 10g as database. I notice when I try to develop in the same PC, I would only be able to make several page request and transition and I immediately get IO exceptions. But I download the same code in a different PC and connect to the said database PC. It does not kick me out immed...

appfuse: Embedded error: java.sql.SQLException: Field 'x' doesn't have a default value

appfuse: Embedded error: java.sql.SQLException: Field 'x' doesn't have a default value ...

Java Web Start: unsigned cglib

I am using hibernate on the server side with a client application started via Java Web Start. I can't sign the jars (I'd like to but I can't). I get a permission exception when I get a POJO with lazy fields. Caused by: java.security.AccessControlException: access denied (java.util.PropertyPermission cglib.debugLocation read) at java...

Oracle legacy table without good PK: How to Hibernate?

I have legacy tables in an Oracle database which i'd like to access from a Java application with Hibernate. The problem is: the tables don't have good primary keys. For instance, a table would look like this: create table employee ( first_name varchar(64) not null, last_name varchar(64) not null, hired_at date, depar...

ScheduledExecutorService with variable delay

Suppose I have a task that is pulling elements from a java.util.concurrent.BlockingQueue and processing them. public void scheduleTask(int delay, TimeUnit timeUnit) { scheduledExecutorService.scheduleWithFixedDelay(new Task(queue), 0, delay, timeUnit); } How can I schedule / reschedule the task if the frequency can be changed dyna...

Can you recommend a java portlet software?

Hi, Currently I am developing java webapps using spring-mvc. I would like to add a protlet feature to my webapps (something similar to Jira's homepage). Can you recommend a software which will give me this feature? Since I am already using spring-mvc,I would rather use a third party instead of a new framework. ...

How to get max and min value of array

How can I get the max and min value of array without calling other method? Public triangles{ for (Polygon p: triangles){ int [] x = p.xpoints; int [] y = p.ypoints; } // I dont know how to get the max and min of array X and Y since both array are declared inside the loop. } ...

Java text formatting

How can I format a string of text, like givenname, surname, telephone ect to look like columns? this won't do it: String customer = "\t"+surname+"\t"+givenname+"\t"+blablabla ...

How to prevent apache http client from following a redirect

I'm connecting to a remote server with apache http client. the remote server sends a redirect, and i want to achieve that my client isn't following the redirect automatically so that i can extract the propper header and do whatever i want with the target. i'm looking for a simple working code sample (copy paste) that stops the automatic...

I need to make new database in mysql with Java

How can I dump database schema to MySQL database with Java JDBC conncetor? I have my database schema in text file. ...

MySQL Prepared Statements vs Stored Procedures Performance

Hi there, I have an old MySQL 4.1 database with a table that has a few millions rows and an old Java application that connects to this database and returns several thousand rows from this this table on a frequent basis via a simple SQL query (i.e. SELECT * FROM people WHERE first_name = 'Bob'. I think the Java application uses client si...

Spring DI, Domain Model & best practices

Is it a good idea to not inject Domain Models in Spring. It saves some XML, and what is the use of injecting domain model anyway. For services and DAO, I want to decouple so I use DI, but Domain Model usually flows all the way from Web to DAO - sort of a vertical layer running through the horizontals. What do you think? Good or bad? Ar...

Generating the same random SecretKey twice

I have a need to generate a random SecretKey, in Java, which I will be able to regenerate at some future point. The idea is that this key is unique to the machine on which it is created and isn't stored anywhere. I'm attempting something like this: KeyGenerator keyGen = KeyGenerator.getInstance("DESede"); String hostname = InetAddress....

Mapping Java ArrayList<CustomClass> and Flex ArrayCollection

Hello Community! I'm currently trying to map a java ArrayList with a Flex ArrayCollection, through LCDS. My Flex application does call the Java method that returns the ArrayList, but I haven't managed to retrieve the ArrayList to display it in a DataGrid, on Flex side. JavaSide: I have 2 classes: - Jco_test.java: it contains the meth...

Binding an Object Array to a Front-End in Java Server Faces

I have a Servlet which is called upon an Action and this Servlet is suppose to return a List of Objects. Now by having the Data Structure at the end of my Post my Servlet calls the Person.fetch() which returns an list/array of Persons. I want my Java Server Face to iterate through this list and call the getPresentation method on each ob...

Javafx and wav files

Hi. I'm playing around with javafx and I have modified the code of the MediaPleyer demo trying to reproduce a wav file. It doesn't work. /* * Copyright (c) 2009, SUN Microsystems, Inc. * All rights reserved. */ package javafx.tools.fxd.demos.mediaplayer; import javafx.scene.*; import javafx.scene.media.*; import javafx.stage.*; va...

Generics and collections - method undefined for type

I'm working on a project, and I'm slightly stuck on one aspect of it. I need to create a class which can manipulate collections of instances of other classes. As part of this, it creates a wrapper object for each instance which has to be able to not only hold the instance, but perform certain operations on it (including equals/hashcode...

What is the best Java SIP Stack around ?

What is the best Java SIP Stack I can use. I'm looking for Stable, Efficient, Rich Feature-Set, Stable & Bug-less :) ...

How to convert list type in Java hibernate

Hello there. In java application I use hibernate criteria queries, for example: Criteria criteria = session.createCriteria(Any.class); ... List<?> list = criteria.list(); and I definetly know that result list contains only objects of type Any but I don't know if it's possible to get list of type defined above? In this case, if I ...