Skip to content

Display Hibernate Query in JTable

I’m seeking an efficient way to display an SQL table queried via Hibernate in a JTable. It would probably be preferable to use the List returned by that (In this case, that would make a list of Files objects (where Files is an internal class, not java.io.File)), but I won’t be picky as long as it …

How do I use optional parameters in Java?

What specification supports optional parameters? Answer There are several ways to simulate optional parameters in Java: Method overloading. void foo(String a, Integer b) { //… } void foo(String a) { foo(a, 0); // here, 0 is a default value for b } foo(“a”, 2); foo(“a”); One of th…

Java Large Files Disk IO Performance

I have two (2GB each) files on my harddisk and want to compare them with each other: Copying the original files with Windows explorer takes approx. 2-4 minutes (that is reading and writing – on the same physical and logical disk). Reading with java.io.FileInputStream twice and comparing the byte arrays …

How do I access a config file inside the jar?

I’m using FlatPack to parse and load data from flat files. This requires loading a config file that stores mappings of the columns of the flat file. I have a constant to define the location of the mapping file: I have a parse(File dataFile) method that actually does the parsing: When I jar up everything…

How can I avoid ResultSet is closed exception in Java?

As soon as my code gets to my while(rs.next()) loop it produces the ResultSet is closed exception. What causes this exception and how can I correct for it? EDIT: I notice in my code that I am nesting while(rs.next()) loop with another (rs2.next()), both result sets coming from the same DB, is this an issue? A…