java

Java Driver.getConnection() yields "Connection Refused" from mysql on live system, not dev.

Pretty straightforward stuff, here -- I'm just not good enough with mysql to understand what it wants from me. I've got a short java test-case that opens a connection on mysql on my dev system but, when I try to put it to my server, it fails. Any help in tracking this down would be most appreciated. Thanks! Test Code import java.ut...

Good design: How to pass InputStreams as argument?

Hello! I've got a big file on which I'm opening a FileInputStream. This file contains some files each having an offset from the beginning and a size. Furthermore I've got a parser that should evaluate such a contained file. File file = ...; // the big file long offset = 1734; // a contained file's offset long size = 256; // a containe...

enums for constants in java - is this good style?

In java <1.5, constants would be implemented like this public class MyClass { public static int VERTICAL = 0; public static int HORIZONTAL = 1; private int orientation; public MyClass(int orientation) { this.orientation = orientation; } ... and you would use it like this: MyClass myClass = new MyClass(My...

How to create a distribution minus some packages in maven ?

I have a maven project with the following packages (for illustration only): Root: src/main/java /com/foo /com/foo/api /com/foo/impl Now I want to create a jar which includes only code in /com/foo/api and /com/foo/impl. How does one hack pom.xml to do this ? Thanks all. ...

Java TimeZone Files

Timezone information for Java are kept in a folder called "zi". For eg. C:\Program Files\Java\jdk6\jre\lib\zi files in this folder are in binary format. But it is very important for me to see exactly what they say. Can anyone share a way, to read these files, or are they Sun proprietary? ...

In Java: How to handshake a secured connection using Keystore and Truststore certificate?

If I have 2 terminals A and B. T-A is connect T-B over secured socket connection. I need to write code to implement a connection between the 2 terminals. How do I do handshake such connection using Keystore and Truststore. Another word, where do I place keystore/truststore certificate file? (T-A or T-B) Any good advice or good example ...

How do I fix "The expression of type List needs unchecked conversion...' ?

In the Java snippet: SyndFeedInput fr = new SyndFeedInput(); SyndFeed sf = fr.build(new XmlReader(myInputStream)); List<SyndEntry> entries = sf.getEntries(); the last line generates the warning "The expression of type List needs unchecked conversion to conform to List<SyndEntry>" What's an appropriate way to fix this? ...

Disable character echo on Java network connection

I have a Solaris daemon written in Java6. Clients can connect to it using a telnet style interface. They telnet to a particular port, and I read lines of input and act on them. At one point in I need to prompt the user to enter a password, and while they're entering that I want to disable the echoing of characters back to the telnet cli...

Is there a good command line argument parser for Java?

Is there a good options parser framework/library for command-line programs written in Java? E.g. the equivalent of Python's optparse? ...

How to download page for jad file at servlet?

Dear Sir/Madam, I have a java me application and now I want to place that application at the server. I want to write the download page with servlet. I mean when the user keys in the servlet url and hit to that servlet, my jad file will send to the phone(user no need to click to download button or link.After page loading, the servlet wil...

Java regexp for file filtering

I would like to build a regexp in Java that would be passed in a FilenameFilter to filter the files in a dir. The problem is that I can't get the hang of the regexp "mind model" :) This is the regexp that I came up with to select the files that I would like to exclude ((ABC|XYZ))+\w*Test.xml What I would like to do is to select all ...

Generated equals in Webservice Stub

All the generated webservice-stubs from our backend have an equals-method similar to this one: private java.lang.Object __equalsCalc = null; public synchronized boolean equals(java.lang.Object obj) { if (!(obj instanceof PropertyData)) return false; PropertyData other = (PropertyData) obj; if (obj == null) return false; ...

Java GUI Creating Components

I hope it is correct term-wise to say that components in a GUI is like JButton, JPanel, JTextField, all that good stuff. I want to create a text field that takes in an integer. Then a submit button can be pressed and based on the integer that was inputted, create that many textfields in a popup window or whatever. I have no clue, could...

How to generate a signed PDF w/o green checkmark

I'm signing PDF's using iText. I'm including a graphic in the signature. This works, but the green checkmark (or yellow question mark) that shows when the document is verified interferes with the graphic I inserted, making the end result look ugly. It either shows up above or below the signature graphic, but I can't get it to disappear....

System.currentTimeMillis() vs. new Date() vs. Calendar.getInstance().getTime()

In Java, what are the performance and resource implications of using System.currentTimeMillis() vs. new Date() vs. Calendar.getInstance().getTime() As I understand it, System.currentTimeMillis() is the most efficient. However, in most applications, that long value would need to be converted to a Date or some similar object to ...

Java JFrame: howto parse recursively through componets (i.e. if using JScrollPane)

I'm using TableLayout for my swing GUI. Initially only some basic labels, buttons and text fields where required which I could later on access by: public Component getComponent(String componentName) { return getComponent(componentName, this.frame.getContentPane()); } private Component getComponent(String componentName, Component co...

what does it mean when a bug doesn't crash the program

The title says it all. No dire need to know, I'm just curious. Sometimes Eclipse comes up saying "hey you should debug this line!!!" but doesn't actually close the program. I can then continue to play big two, and even go through the same events that caused the error the first time and get another error box to pop up! The bug is simple,...

How to get real string height in java?

I'm using the FontMetrics.getHeight() to get the height of the string, but it gives me a wrong value, cutting off the descenders of string characters. Is there a better function I can use? ...

Associate arbitrary data with ejb call context

I've got a bunch of stateless ejb 3.0 beans calling each other in chain. Consider, BeanA.do(message) -> BeanB.do() -> BeanC.do() -> BeanD.do(). Now i'd like to access message data from BeanD.do(). Obvious solution is to pass message as a parameter to all that do() calls (actually that's how it works now), but i want some nicer solution...

XmlTextAttribute and CDATA

We have a part of our application where our users can create objects containing html, javascript and css through custom made Wysiwyg components. Those objects are at some point serialized and later deserialized. However, since our users/clients are located all over the globe, they sometimes input characters that cause grievance during de...