java

Can I update the result (sys_refcursor) of an Oracle stored procedure (in Java)?

Given the following function: create or replace FUNCTION "GETADDRESSES" RETURN sys_refcursor IS address_cursor sys_refcursor; BEGIN OPEN address_cursor FOR SELECT * FROM Address; RETURN address_cursor; END; I would like to be able to make changes to this result set in Java and post the changes back to the data...

Is there a Java library equivalent to Microsoft/.NET System.IO.Packaging?

Is there a Java library equivalent to System.IO.Packaging. If so what is the experience of unpacking DOCX files editing DOCX files building DOCX files from scratch. ...

How do I test with DBUnit with plain JDBC and HSQLDB without facing a NoSuchTableException?

I am trying to use DBUnit with plain JDBC and HSQLDB, and can't quite get it to work -- even though I've used DBUnit with Hibernate earlier with great success. Here's the code: import java.sql.PreparedStatement; import org.dbunit.IDatabaseTester; import org.dbunit.JdbcDatabaseTester; import org.dbunit.dataset.IDataSet; import org.dbuni...

Persisting graph data (Java)

I have an application which utilizes graph (tree-like) custom structures. The structures are not real trees, but pretty much everything is connected together. The quantity of the data is also big (millions of nodes can exist). Tree-nodes can vary in type to make it more interesting (inheritance). I don't want to alter the data-structures...

Is java.sql.Connection thread safe?

To rephrase the question: should I avoid sharing instances of classes which implement java.sql.Connection between different threads? ...

Use MySQL collation in Java

Short Version I'm currently looking into an issue with MySQL collations and how they affect a Set of values (which is mapped using Hibernate, but that shouldn't matter for now). I want to have a Set of Strings using the same collation as MySQL uses. E.g. I want "foobar" and "fööbar" considered equal but "foo bar" and "foobar" considered...

Good Java application to learn OOD

Hi, I'm looking for an open source java application (C# application is also ok), to learn & understand good Object Oriented design. Specifically, I'm looking for interactions with relational database, so that I can understand the finer details between converting an OO design to non-OO structure. I had a look at some ORM samples. While...

How do I redirect to the current page in Servlet Filter?

I have a page say: /myapp/test.jsp?queryString=Y. The filter needs to redirect to current page. It should go to /myapp/test.jsp (without the query string). The below seems to bring it to to the context root: /myapp. I am running in WAS6.1. public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOExce...

How to use join in an HQL update?

I know how to join tables in an SQL update but how do I do it in HQL? Long story: I have items which I process in a run. Each run as an ID and I have a many-to-many relation between items and runs (which is in an extra table). Now I want to set the state of all items used in a certain run. The naive approach looks like this: update It...

Set a String to "" or leave it null?

I have some String variables which are getting the values from invoking the function getParameter() and some of this variables will probably be null. Later, I will evaluate this variables using equals() method. Should I set all the String variables to the empty String ("") if they are null to avoid any problems? ...

Is there any way for DBUnit to automatically create tables?

I just realized that DBUnit doesn't create tables by itself (see How do I test with DBUnit with plain JDBC and HSQLDB without facing a NoSuchTableException?). Is there any way for DBUnit to automatically create tables from a dataset or dtd? EDIT: For simple testing of an in-memory database like HSQLDB, a crude approach can be used to ...

Why 2 bins for exe's in jdk?

When i am installing JDK(TM) Update 10, it installs the following four features : -> Development Tools -> Demos and Samples -> Source Code -> Java DB With last three features, i have no probz at all. Now Development tools contains :- java devlopment kit (to develop java applications, here jdk1.6.0_10) public jre (which is alway...

Analog of StringBuilder for BigDecimal.

I've got a list of BigDecimals to sum. If they were Strings to concatenate, I would use StringBuilder to reduce object creation. Is there something similar for BigDecimal? Or maybe I shouldn't bother about it? Is optimization of BigDecimal creation worth putting effort to it? BigDecimal result = BigDecimal.ZERO; for (CashReportElement e...

putting data from 2 classes into one array with 2 packages

Ok. since my confusion has died down i think i may have worded my question wrong. i have the classes "GenericMessage" "email" and "fax" in one package. "email" and "fax" have one variable in them which is a String. all of the above classes are in a package named "Message". now i have created a new package named "Outbox" it contains ...

Java - copying arraylist objects

Hi I am trying to copy the contents of an arraylist into another object. I tried initializing the new ArrayList object in the following ways newArrList.addAll(oldArrList); and newArrList = new ArrayList(oldArrList); But every time I make a change to one of the array lists, the value also changes in the other ArrayList. Can someon...

Eclipse (IBM AST) cannot find imports to existing files

I am having issues with IBM's AST (which is based on Eclipse 3.2) importing files. For example, I have a class file named "Status" in the following package: com.test.model When I give another class in the project the following statement: import com.test.model.Status; the IDE complains that it cannot resolve the import. There are no ...

Override variable or force usage?

I want to force a class to define a certain variable from the class it implements. e.g. class Fruit{ String name; // Cause each fruit has a name } //Apple wants to get an error if it does not use the name variable class Apple implements Fruit { String name = "Apple"; } Is there a way to do that? Just like java.io.Serializab...

How to redirect output from Groovy script?

I wonder if there is any way I could change the default output (System.out) for the groovy script that I'm executing from my Java code. Here is the Java code: public void exec(File file, OutputStream output) throws Exception { GroovyShell shell = new GroovyShell(); shell.evaluate(file); } And the sample groovy script: def na...

How do you include .jar files in a Java library?

How do you include .jar files in a Java library so that it can be imported directly in a program? ...

Encoding java Cookie value

Hi! How should you encode the actual value for a Java Cookie object? I cannot pass characters like '=' or any character outside US-ASCII. /Br joynes ...