Wnen I use external resources such as files or DB connection I need to close them before I let them go.
Do I need to do the same thing with Swing components ? If yes then how ?
...
Please enlighten me.
public class SomeObject{
private String strSomeProperty;
public SomeObject(String strSomeProperty){
this.strSomeProperty = strSomeProperty;
}
public void setSomeProperty(String strSomeProperty){
this.strSomeProperty = strSomeProperty;
}
public String getSomeProperty(){
retur...
My company currently evaluates the development of a Java FAT client. It should support a dynamic GUI and has as much logic as possible on the server side. Hence the idea came up to send the screen as XML to the FAT client, show it to the user and send the entered data similar to "html form" back in a structure like:
<fields>
<field ty...
I have an xml file ('videofaq.xml') that defines a DTD using the following DOCTYPE
<!DOCTYPE video-faq SYSTEM "videofaq.dtd">
I am loading the file from the classpath (from a JAR actually) at Servlet initialization time using:
getClass().getResourceAsStream("videofaq.xml")
The XML is found correctly, but for the DTD in the same pac...
How would you run the Selenium process (thread) from a Java process so I don't have to start Selenium by hand?
...
I'm building a jar of my current application, which required several JVM arguments to be set.
Is there a way of setting these JVM arguments in a file rather than on the command line?
I've done some hunting and it looks like I might be able to do something witha java.properties file, possibly by setting a java-args, but I can't find any...
My program receives large CSV files and transforms them to XML files. In order to have better performance I would like to split this files in smaller segments of (for example) 500 lines. What are the available Java libraries for splitting text files?
...
Consider the code:
PreparedStatement ps = null;
ResultSet rs = null;
try {
ps = conn.createStatement(myQueryString);
rs = ps.executeQuery();
// process the results...
} catch (java.sql.SQLException e) {
log.error("an error!", e);
throw new MyAppException("I'm sorry. Your query did not work.");
} finally {
ps.close();
rs.cl...
In java, what is the best way to convert a double to a long?
Just cast? or
double d = 394.000;
long l = (new Double(d)).longValue();
System.out.println("double=" + d + ", long=" + l);
...
I have a table with a timestamp field of type datetime. I need to aggregate the data between a defined start and end time into x groups representing time intervals of equal length, where x is supplied as function parameter.
What would be the best way to do this with Hibernate?
EDIT: some explanations
mysql Table:
data_ts: datetime pk...
I have an application that I want to export high-resolution (or rather, high pixel density?) images for printing - for example, I want images that print at 250 dots per inch (DPI), instead of the default, which I understand to be 72 DPI.
I'm using a BufferedImage with a Graphics2D object to draw the image, then ImageIO.write() to save t...
Are the threadlocals variables global to all the requests made to the servlet that owns the variables?
I am using resin for the server.
Thanks for awnser.
I think I can make my self more clear.
The specific Case:
I want to:
initialize a static variable when the request starts the execution.
be able to query the value of the vari...
I have a legacy JBoss 4.0.4/EJB 2.1/PostgreSQL system with zillions of "transaction scripted" procedures as server EJB methods, and many of them have very slow and clumsy execution times due to bad programming practices (like creating temporary tables everytime, etc).
Is there something I can plug in JBoss (Aspect-Like) to monitor the e...
Hi all,
I'm trying to encrypt some integers in java using java.security and javax.crypto.
The problem seems to be that the Cipher class only encrypts byte arrays. I can't directly convert an integer to a byte string (or can I?). What is the best way to do this?
Should I convert the integer to a string and the string to byte[]? Th...
Yesterday I had a two-hour technical phone interview (which I passed, woohoo!), but I completely muffed up the following question regarding dynamic binding in Java. And it's doubly puzzling because I use to teach this concept to undergraduates when I was a TA a few years ago, so the prospect that I gave them misinformation is a little d...
I am trying to make IBM jre to use PCF fonts from default X11 installation on my linux box. In particular adobe-helvetica font. I have toyed to modify fontconfig.properties in jre/lib folder but no matter what I do Java seams to use some other fonts. I guess there is some algorithm how java VM tries to link java logical fonts to actual p...
Ok, this is working on windows. My Java app is running and functioning normally
javac -classpath .;ojdbc14.jar -g foo.java
java -classpath .;ojdbc14.jar foo
However, when I do the same thing on Unix I get this error:
ojdbc14.jar: not found
What am I doing wrong? I know the ";" is telling my shell that ojdbc14.jar is a new comma...
I'm working on a java program, and I have several vectors defined and filled (from a file) inside a method. I need to return the contents of all the vectors from the method. I have heard you can put them all in one object to return them. Is that possible, and if so, how? If not, do you have any possible solutions for me? Thanks in a...
The top of my web.xml file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd"
version="2.5">
But I still get the wa...
I've created a UserObject and RoleObject to represent users in my application. I'm trying to use hibernate for CRUD instead of raw JDBC. I've successfully retrieved the information from the data base, but I can not create new users. I get the following error.
org.springframework.web.util.NestedServletException: Request processing fa...