Win a copy of Head First Android this week in the Android forum!

Andris Jekabsons

Ranch Hand
+ Follow
since Jan 20, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Andris Jekabsons

Hi!
I'm trying to learn how to use Velocity and Maven to generate some HTML pages. (I'm using Velocity Engine that comes with Maven 2.0.5)
The problem I have is that my .vm file does not "see" structure of the Maven's site declaration.

When I run Maven without reference to my .vm file, it generates HTML file with the structure of the site as defined in /src/site/site.xml file (as well as the contents of the index.apt file).
This works fine.

Then I add my custom Velocity file "maven-site.vm" and reference it in the pom.xml file:I can change the generated HTML page with the help of my Velocity file. However, when I try to retrieve the "site.xml" structure using $siteDescriptor.getChild() (for example, $siteDescriptor.getChild( "bannerLeft" ) ), I always get null.
Why is it so?

Is there anything else I have to define?

Or is my file structure incorrect?
Here is the structure of my sample project:
I've spent a lot of time searching for solution, but haven't been able to find the answer.
Thanks!
[ August 19, 2007: Message edited by: Andris Jekabsons ]
Thanks for the response. It looks like I was using the correct methods, but the problem has disappeared now. Just as it "mysteriously" appeared when a previously functioning Java code was moved to Oracle (btw, a clob wasn't creating any problems, only a blob), it has "mysteriously" disappeared. I changed some code in the method, and now it works - even though I didn't change how I write data to the blob.
Go figure!
I have a Java class that writes something to an Oracle BLOB. With a method like this (I fill the blob and return it to the caller):
To call this method, I get a connection to Oracle, call a stored procedure which returns an empty blob (which I then pass to the fillBlob() method):
The stored procedure just returns a temporary blob and contains one line:
This works fine. The problem starts when I put that class in Oracle as a Java source, and call the class from an Oracle procedure (a requirement): I am getting 'ORA-24813 cannot send or receive an unsupported LOB' error.
If my Java class returns something else (or just null), I don't get an error. So, I think the error is because I return the blob I have received as an argument.
What can I do to fix the error, or how else can I achieve my goal?

P.S. I've tried this on two different Oracle databases (10.2.0.1.0 and 10.2.0.3.0)
[ July 30, 2007: Message edited by: Andris Jekabsons ]
Thanks! I ended up converting all Headers from getAllHeaders() method to a custom serialized counterpart (so that I could store them as a single object), and getting the content from the getContent() method and serializing various its parts.
14 years ago
Is there a "nice" way to store Message object for easy retrieval later?
I am connecting to a mail server to retrieve emails, which I need to store in DB for later processing. Unfortunately Message (POP3Message in my case) is not serializable. Also, the "writeTo()" method does not really work for me, because it outputs the Message as a string, and if I wanted to reconstruct the Message object, I would need to parse it manually.
Does anybody know a way to achieve this?
14 years ago
You can copy only references of the objects:
Here the objects will not be copied (only their references).
Is this what you are looking for?
14 years ago
Did you mean " new MyClass().NonStaticMethod() "?
This creates a new instance of MyClass, so if your constructor does some time consuming stuff, it will unnecessary decrease performance.
At any rate, this is not a good coding style.
14 years ago
Take some mock exams (for example, the Javaranch mock exam) and see how you score.
14 years ago

Originally posted by Chandra Bhatt:
[QB]double []d = new double[10];

Or even better (IMHO):
double[] d = new double[10];
You can divide your assignment in several parts: receiving input from user, writing to a file and performing calculations on numbers. Read more about the first two on Java Tutorial and then you can ask more specific questions.
14 years ago
P.S. Also, notice that your method will throw a NullPointerException if customerId is null. This might or might not be something you want.
14 years ago
Well, you don't have too many alternatives:
1) throw an exception if no customer is found; I think it's not needed, unless such a case is really exceptional (an error) in your program
2) return a new customer (probably not suitable here, as you are most likely looking for an existing one)
3) just return null (what I would do in most cases)
14 years ago
I think you should look into the Singleton pattern. That allows you to have only one instance of a class; similar to having only one "instance" of a static variable within a class.
This is, as I understand it, what you are looking for.
[ May 29, 2007: Message edited by: Andris Jekabsons ]
14 years ago
You can encode the user ID (and whatever other info you need) and associate the encoded number/characters with the user. For example, generate a simple hashCode (or something more sophisticated) from the user ID, and store both pieces of info in your db. Send the link to user with that encoded info as a URL parameter. When the user clicks on it, you can get the encoded URL parameter and retrieve the user ID from the database.
I think that's what most real life systems do.
14 years ago