JDBC offers me 3 different datatypes for time-related fields: "Date", "Time" and "Timestamp". Can someone provide a simple summary of what each one is used for and how to choose which to use for a given problem?
...
I'm working on my first java struts2 webapp and want to be able to inject bean parameters into any arbitrary class that is called. But I find that I can only do this with struts action classes...
Let's say I have this bean in my applicationContext.xml file:
<bean id="BeanTest" class="BeanTest">
<property name="test" value="someval...
I'm trying to run org.hibernate.tool.ant.EnversHibernateToolTask as suggested in the rather terse guide to Envers (2nd line of table, Documentation has a link to a PDF). Here's my ant task tweaked so it successfully finds org.hibernate.tool.ant.EnversHibernateToolTask and org.hibernate.tool.ant.HibernateToolTask; now it can't find org.ap...
This is after the last unsuccessful run of my program. I notice that the file size has changed and I can no longer run the Java class for my program:
root@dbs01 ~
$ ls -l lifecycle-0.1-SNAPSHOT.jar
-rw-r--r-- 1 root root 24740243 Jun 4 20:48 lifecycle-0.1-SNAPSHOT.jar
This is after I copy the new copy of the original JAR f...
I have a LinkedHashMap<String,Object> and was wondering what the most efficient way to put the String portion of each element in the LinkedHashMap into a JList.
...
I need to set up a legacy app that uses Tomcat 4 and runs using the 1.4 JDK.
I tried to install the linux JDK 1.4 from the sun download site on Ubuntu 9.04 but it wouldnt install.
Is it possible to install JDK 1.4 on the 64 bit version of Ubuntu?
When I try and install the j2sdk-1_4_2_19-linux-ia64.bin version i get the following erro...
I'm a newbie Java coder and I just read a variable of an integer class can be described 3 different ways in the api. I have the following code..
if (count.compareTo(0)) {
System.out.println(out_table);
count++;
}
This is inside a loop and just outputs out_table.
My goal is the figure out how to see if th...
I have a java servlet (class) which populates form data.
//encode string for special characters
String encodedString = URLEncoder.encode(desc, "UTF-8");
out_table.append("<form name=\"masinsert"+id+"\" method=\"GET\" action=\"MASInsert2\">\n");
out_table.append("<input type=hidden id=\"partnumber"+id+"\" name=\"partnumber"+...
I'm inserting text from a Java application into a Postgresql database, but it all crashes when a ' char is encountered in the String. I've tried using replaceAll(" ' ", " \\' "); even diffrent variants of it with more \ chars, yet it still puts a single ' in the String without the escape sign.
Is there any way of replacing the ' with a...
I"m guessing i'm getting this error because the string is trying to substring a null value. But wouldn't the ".length() > 0" part eliminate that issue?
Here is the Java snippet:
if (itemdescription.length() > 0) {
pstmt2.setString(3, itemdescription.substring(0,38));
} else {
pstmt2.setString(3, "_");
}
I got this error:
...
How can I access request headers from a SessionListener?
I need to set a timeout on the current session when it is created. The timeout needs to vary based on a header in the HttpServletRequest. I already have a SessionListener (implements HttpSessionListener) that logs the creation and destruction of new sessions, and it seems to be th...
How do I increase the volume of an outgoing wav audio stream using Java? I'm having issues with various Java TTS engines and the output volume of the synthesized speech. Is there an API call or a doo-hickey.jar I can use to pump up the volume?
...
On my project, we have been writing our own IP header parsing code for some time now. I'm starting to wonder if our time could be spent better elsewhere. A google search has not yielded much of use.
Basically, what I am looking for is a third party library that will be able to parse out all of the meaningful information out of a IP pack...
I'm new to using JAXB, and I used JAXB 2.1.3's xjc to generate a set of classes from my XML Schema. In addition to generating a class for each element in my schema, it created an ObjectFactory class.
There doesn't seem to be anything stopping me from instantiating the elements directly, e.g.
MyElement element = new MyElement();
where...
Is there a way to map a factory method in Hibernate (as opposed to having Hibernate call a default constructor and reflectively set properties or fields)?
And if it can't be mapped, does Hibernate provide a hook for custom object creation on a class by class basis?
Thanks!
...
In this answer to a question I asked. Kathy Van Stone says that adding an array like so
jList1.setListData(LinkedHashMap.keySet().toArray());
is a better way than to do it like this
jList1.setListData(new Vector<String>(LinkedHashMap.keySet()));
I am wondering if there was any truth to this and if so what the reason behind it was.
...
I have a JTable in which i set the column sized like following,
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
table.getColumnModel().getColumn(0).setPreferredWidth(27);
table.getColumnModel().getColumn(1).setPreferredWidth(120);
table.getColumnModel().getColumn(2).setPreferredWidth(100);
table.getColumnModel().get...
When i deploy bookstore1 application from java ee 5 tutorial onnetbeans 6.7 rc1 and glassfish 2.1 i get error :
Deploying application in domain failed; Error loading deployment descriptors for module [bookstore1] -- UnsupportedClassVersionError: Class com.sun.bookstore1.servlets.CashierServlet has unsupported major or minor version num...
** Why is the class CanvasPane not included in the Java API?.
import javax.swing.*;
import java.awt.*;
import java.awt.geom.*;
/**
* Class Canvas - a class to allow for simple graphical
* drawing on a canvas.
*
* @author Michael Kolling (mik)
* @author Bruce Quig
*
* @version 2008.03....
I've got Java code which makes a long term socket connection to a home automation device to monitor it for activity/events. The problem is if the device is rebooted or gets power cycled the Java code should automatically reconnect as soon as possible. Any ideas for how to detect a dropped connection on the Java side, preferably without...