Jim Cross

Greenhorn
+ Follow
since Nov 20, 2003
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Jim Cross

Hi all,

I need to build a service which is used for persistence of arbitrary data. Typically this may be structured data saved out from spreadsheets...we don't care what the data structure is, or even the format (may be json, xml, yaml etc).
The service must be available over HTTP and have a WebDAV interface.
The service must also send out update messages over JMS for persisted data (inserts and updates). Update messages must be consistent with the state of the database (i.e. the last update message sent must be consistent with the database in the database).
We aim to complete small writes in under 100ms and reads in under 50ms.

Our current service is based on Slide, with an Oracle database, and is deployed in London only. The main problem currently is that the WAN link between Asia and London is awful (250ms round trip), so cross-region performance is not acceptable.
All data from all regions must be available globally, as it is read/written from many regions.

Any recommendations on suitable architectures, open source components etc to achieve these requirements much appreciated.
My current thinking is to have regional caches to improve read performance and force writes to be asynchronous on the client side, but I'd like to avoid forcing async writes if possible.

Thanks

Jim
16 years ago
After a bit more investigation, it's definitely not a driver loading issue, as I can query the db from a Servlet in the same instance by explicitly loading the driver using
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
17 years ago
Hi guys,

I'm experiencing a problem connecting to Oracle 9 from Tomcat 5.5. Have found loads of posts on the net describing the problem, but none of the solutions work for me.

The exception I get is:
Cannot create JDBC driver of class '' for connect URL 'null'
java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getDriver(DriverManager.java:243)

Having run this through the debugger in Tomcat, it's definitely a problem loading the class - when I step into DriverManager.loadInitialDrivers(), I can see that drivers in the following snippet is always null:



I've put ojdbc14.jar under common/lib. I have the following in server.xml:



And in web.xml:



I know the classname is correct, as I have a standalone project which loads the driver and connects to the database fine - the problem only occurs under Tomcat.

I'm really tearing my hair out with this one, so any help greatly appreciated!

Cheers,

Jim
17 years ago
In my test application, I have two tables; J_TRADE and J_CASHFLOW. Trades may have zero-to-many associated cashflows.

J_TRADE has ID as its primary key, and a version column.
J_CASHFLOW references the trade ID column and the trade VERSION column.


The mappings are as follows:



Clearly from this, the cashflow class isn't aware that it references the trade version. So, while the cashflow trade id does get populated correctly on insert, the cashflow trade version doesn't.

Is there any way to make the cashflow reference the trade version, without making ID and VERSION a composite key in the trade table, and having to handle the trade id and version increments myself?
I tried that yesterday, but it didn't allow me to specify those columns in both the key and the composite element.
However, I finally got it working by doing the right way (I think!):

OK, that solved that problem

Another question related to this.
Trades have a one-to-many relationships with cashflows. So the cashflow table contains the columns TRADE_ID, TRADE_VERSION, which are a foreign key into the TRADE table.

Using the following in my Hibernate mapping file, when I load a trade it now loads a set of cashflows. However, while it populates most of the properties correctly, it doesn't populate the tradeId and tradeVersion properties of the cashflows...



I guess this is because the column element only specifies the database column, and not the Java bean property to map that column on to. Any ideas how I can specify this?
Thanks Scott.

If you update entity with ID 12345 from version 1 to version 2, do you keep version 1 in the table and insert version 2?



Yes, so it's update as insert, and we maintain the full history of each trade in the table.
I have a table in my database which is versioned, so each record consists of ID, VERSION, TRADE_DATE, VALUE_DATE, etc where the primary key is a composite of ID and VERSION.
So a trade with ID 12345 starts with VERSION 1, and this version number gets incremented on each update.
Is there a recommended pattern for handling this in Hibernate? My current understanding is that I need to use the composite-id tag, and create a TradeKey inner class in my Trade bean class, with the TradeKey class holding the ID and VERSION. I then have to handle the generation of trade ids and version myself. Is this the best way to do it?
If so, is there any way to create my own SQL prepared statements using Hibernate? I know you can create normal SQL queries, but I'd ideally like to use a prepared statement which parameterises the object type (my key generator table in the database as it is currently holds keys for various object types - trade, cashflow etc). If possibly I'd like to query and update this table using a prepared statement. If this isn't possible using Hibernate, I'll have to do this part of it using standard JDBC, which I'd rather avoid...

Also, if I was looking to refactor this trade table to make it more suitable for Hibernate in the future, what would be the best way to structure the primary key, given that each trade must maintain the "trade id" and incremented version number throughout its life?

Any help much appreciated.

Thanks,

Jim
Hi guys,

Just tried to register on the Hibernate forum (forum.hibernate.org), but there seems to be a problem with the e-mailer functionality (php eh? ;-))
Looks like I'm registered but haven't received the activation e-mail.
Could someone who is already registered please put a post on the site to draw the admin's attention to the problem?

Thanks,

Jim
I believe in the new S&B book it states that the instance variables are not initialised until after the call to Object() (the Object constructor, that is).
So super() gets called all they way up the inheritance hierarchy. When it reaches Object, its constructor gets called, then instance variables are initialised, then the constructors complete all the way down the inheritance hierarchy.
So it is the case that super() is inserted as the first line of the constructor.
[ February 12, 2006: Message edited by: Jim Cross ]
Hi all,

One of the mock questions on the S&B SCJP 1.5 CD is as follows:

Which results are NOT possible:
A a1bc23
B abc123
C 12c3ab
D 1ab3c2
E 123abc
F The code does not compile
G An error occurs at runtime

I can't seem to get the right answer.
The way I read it, the only thing that is guarateed is that the letters will be printed in ascending order, and the numbers will be printed in ascending order. There is no guarantee though that either thread will start first, and that the letters and numbers won't intermingle.
Therefore, to me the correct answers seem to be C and D.

Anyone else agree/disagree?

[ February 11, 2006: Message edited by: Jim Cross ]
[ February 11, 2006: Message edited by: Jim Cross ]
Just working through the Sierra & BAtes SCJP 5.0 book (great book, exactly what I need - learnt a huge amount already).
Question 16 in Chapter 7's Self test is the following:

Given a method declared as:
public static <E extends Number> List<? super E> process(List<E> nums)

A programmer wants to use this method like this:
// INSERT DECLARATIONS HERE
output = process(input);

Which pair of declarations could be placed at // INSERT DECLARATIONS HERE to allow the code to compile?

A. ArrayList<Integer> input = null;
ArrayList<Integer> output = null;

B. ArrayList<Integer> input = null;
List<Integer> output = null;

C. ArrayList<Integer> input = null;
List<Number> output = null;

D. List<Number> input = null;
ArrayList<Integer> output = null;

E. List<Number> input = null;
List<Number> output = null;

F. List<Integer> input = null;
List<Integer> output = null;

The answer gives B,E and F as all true.

However, whenever I try to compile any of these answers, compilation fails.
Isn't it the case that the call to process(input) would always have to be cast in order to allow compilation? This is because the generic type of the List input must always exactly match the generic type returned from process. As the return type of process is itself generic, at compile time the generic return type of the List returned by process cannot be known...
Hi all,

I am currently writing an application which takes a properties file listing the properties for an arbitrary set of "Adapter" objects. Each Adapter should log to its own log file, with the log file for each specified in the props file.

So, I might have 3 adapters - adapterA, adapterB and adapterC, which I want to log to adapterA.log, adapterB.log and adapterC.log.

The problem I have at the moment is that all instances of the Adapter class log to the same log file - the file specified in the last Adapter object to be instantiated.

The logger object in the Adapter class is non-static, and is initialised as follows:
private Logger log = Logger.getLogger(AdapterWrapper.class.getName());

(I have also tried this without the .getName() method, but it makes no difference).

In the constructor, the following call is made:
DOMConfigurator.configure(log4jFile)

where log4jFile is the name of the log4j file for that specific instance.


Any ideas why all instances share the same file, and any way to get around it?

Thanks,

Jim
Hi,
I'm currently working as a Java developer in a back office development team in an investment bank, and want to learn more about financial modelling while enhancing my J2EE skills. I'm hoping to do this by writing some sample J2EE applications which perform financial modelling (e.g. yield curve calculation, derivative pricing, risk simluation etc)
Has anyone got any recommendations for books or websites to start out with?
Thanks,
Jim
20 years ago