java

assigning a specific record in a ResultSet to a variable

Hi I want to retrieve a set of records from a database, do a rs.next() and then assign the result of this to a variable to pass to a method that will use this record, in the same way that I would without assigning it to a variable and passing it to a method is there any way to do this? I'm using JAVA (1.5) ...

Quick Java question: Which Exception should I use?

Let's assume I'm a complete lazy bum and I don't want to invest the several dozen keystrokes needed for my own Exception class (it's not utterly important which gets used, really). However, to pretend I'm following good practices here, I want a pre-existing one that best fits my situation. Problem: I need to throw an exception when my ...

To add commas in file

Hi All, This is my first question in this forum... I have a file with numerous data fields (both numeric and characters) in the file. I want to delimit the file with set of delimiter length like 2,5,1,9,6 etc. (Alternatively: I have a list of field lengths such as 2,5,1,9,6, and I want to insert comma delimiters in (a copy of) the sour...

NULL token in JavaCC

I have strange problem with token < NULL: "null" > in my JavaCC parser. In expression like String IsNullClause(): { String res = ""; } { <IS> {res += " IS ";} [<NOT> {res += " NOT ";} ] <NULL> {res += " NULL ";} { return res; } } parser doesn't see NULL token and throws exception that "null" expected. If I chang...

Java Validation Frameworks

I once came across a validation framework for java, where you wrote one method that protected the integrity of the data-type and any CRUD operations on that data-type automatically called this method. Does anyone know what this framework is? ...

Port of Random generator from C to Java?

George Marsaglia has written an excellent random number generator that is extremely fast, simple, and has a much higher period than the Mersenne Twister. Here is the code with a description: good C random number generator I wanted to port the CMWC4096 code to Java, but it uses several unsigned datatypes so I am not sure how to do this ...

Taking contact list from hotmail gmail yahoo in java ?

most of social networks does this. when you register one of them for example twitter it says why dont you invite your friends from hotmail or yahoo or gmail. and expect us to give our credentials and send those mails. I want to implement same feature in java. I tried http://code.google.com/p/contactlistimporter but it has a problem with...

Java/JRuby on Rails vs .NET 3.5... feel like I'm doing it wrong

I'm planning to develop a web-services (SOAP to C++ client) in Java with Metro/Hibernate and front it up with a web-site written in JRuby on Rails, connecting Java modules through JRuby and generally through a database. I already wrote some code and set up everything. Now, I've heard that .NET 3.5 is really powerful and after some read...

Findbugs not finding potential SQL injection vulnerability

I just installed the FindBugs plugin for Eclipse, with the hope that it will help me find SQL injection vulnerabilities in my code. However, it doesn't seem to be finding anything, even when I deliberately put some in. In the following examples, assume staticFinalBaseQuery is declared as follows: public static final String staticFin...

How can I set the schema name used by hibernate entities at query time?

Our application uses Hibernate for ORM, and stores data in several schemas, accessing them with a user whose grants are customized for the application. The schema names are determined at runtime based on data; it's not feasible to include their names in the entity mapping documents. This means that I need a way to tell Hibernate to use...

Update JavaFX window from a java based object

Hello, I am in the process of learning JavaFX and I am looking for a tutorial about updating a JavaFX display with a java object. For example, receive status updates @ 1hz from a server and display them on the fx window. Is this possible? If so, are there any tutorials? Thanks in advance. ...

Application of [L]GPL to Java/C# code

How the [L]GPL license should be applied to Java and C# code ? I know that when Sun JDK become GPL, they did special exceptions for standard libraries. So, if I cannot open my application source and still want to distribute it ... ... could I use GPL'ed library (by import'ing its classes)? ... could I use LGPL'ed one ... could my app...

Simple way to detect unused properties keys?

Given a set of properties files and list of files which may reference keys in those properties files, what's the easiest way to determine which keys are unused? Example: Given a project with files muppets.properties kermit=Kermit the Frog oscar=Oscar the Grouch smurfs.properties papa=Papa Smurf and /WEB-INF/pages/template.jsp S...

Technical tips for writing great JavaDoc

What are your technical tips for writing great JavaDoc? I'm looking for things beyond the standard "Explain the function well" content-based tips. We all know that! (right?) I'm interested in things like these: What tags should definitely be a part of one's JavaDoc, and which ones are not worth remembering? When do you use @see vs. ...

Run GWT shell normal, use -noserver on compile?

I would like to run the GWT shell (the nice little Google pop-up browser window) when "testing" and upon clicking the actual "Compile/Browse" on the tool, compile the program into a different directory and use the -noserver mode to test it on my IIS server. Problem: I have not edited the normal shell script, so it fires off just fine. ...

NoClassDefFoundError on command-line with new NetBeans project

I've created a new J2SE project in NetBeans, and I can run it from the IDE, but when I try to run it using Ant on the command line, I get the following problem: <snip> run: [java] Exception in thread "main" java.lang.NoClassDefFoundError: IndexBuilder [java] Java Result: 1 <snip> Based on the snippet from project.propertie...

Java: What is the preferred Throwable to use in a private utility class constructor?

Effective Java (Second Edition), Item 4, discusses using private constructors to enforce noninstantiability. Here's the code sample from the book: public final class UtilityClass { private UtilityClass() { throw new AssertionError(); } } However, AssertionError doesn't seem like the right thing to throw. Nothing is bei...

Even easier Java/SQL data transfer needed.

So, I'm using jdbc to talk to a MySQL DB. For many a table and for many queries/views, I have created one class which encapsulates one row of the table or the query/table result. Accesses to the DB return one object of such a class (when I know exactly that there's only one matching row) or a Vector of such objects. Each class featu...

favicon.ico in Java WAR file

Can anybody provide some instruction on how to setup a war file to show a favicon.ico in the browser address bar? ...

ArrayList and the problem with adding items

Hi, I please for your help. I apologize for my English, it is still learning. I do one application in GUI in Java. I have one problem. In this application I have an ArrayList that I want to meet with data. User clicks on the button and data from JTextfield shall be placed in Arraylist. When they do so, it is inserted only into the ...