Author |
Message
|
mqsiuser |
Posted: Thu Feb 23, 2012 4:50 am Post subject: |
|
|
 Yatiri
Joined: 15 Apr 2008 Posts: 637 Location: Germany
|
Exceptions/Exemptions always also apply... I should have stated that !!! To all your/my examples !!!
I might also be totally wrong. Then just disprove and we all know better !!!
Things are relative. My statements are just a rule of thumb to guide Java-Developers a bit (I hope the gurus here will agree to me somewhat ... actually I know they do).
rekarm01 wrote: |
mqsiuser wrote: |
Though it must be stated that xslt doesnt honor the on-demand-parser (I guess it doesnt even use one). |
Why must this be stated? Is it actually true? Please explain. |
XSLT uses pattern matching which require the full document to be read and parsed (to at least significant) parts. Someone else to comment please about the on-demand-capabilities of the xslt-parser in Broker, thanks.
rekarm01 wrote: |
mqsiuser wrote: |
1. Do not use CARDINALITY
2. Do not access elements in a list with brackets ([]) and |
Never? Ever? Why not? Given the following hypothetical function:
Code: |
CREATE FUNCTION median(IN REFERENCE sortedData) RETURNS INTEGER
BEGIN
DECLARE N INTEGER CARDINALITY(sortedData.value[]);
RETURN sortedData.value[N/2];
END; |
how might these rules be applied to improve this function's performance? |
The answer to this is, that you might probably not use this function when you have high performance requirements.
You would (probably/likely) combine the extraction (calculation) of the median with the rest of your tranformation code (and not put it into a utility function)!
Do you see that ?! You are applying JAVA thought here and not ESQL thought. You must change your thought: Always think of what the parser/tree-walker (currently) does. If your list contains 100.000 records, he will be very busy with the code that you suggest here. Probably in another place you go through this list anyway... put in the extraction of the median there ("between the lines")... ugly code, but better performance.
Thought when I look twice... thats awkward what you do there, why would you need that? The right answer to you particular questions is: This is a pathological example (an example that does not (or only rarly) apply).
With small lists you might use CARDINALITY, but do not put it in the top of a loop, like " for i < CARDINALITY(...)", instead store it in a variable (e.g. "count") and then use the variable in the loop: "for i < count".
Probably/Likely you will sometimes have to do things like you suggest here, but just be aware of parsing-times. _________________ Just use REFERENCEs |
|
Back to top |
|
 |
Vitor |
Posted: Thu Feb 23, 2012 5:48 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
OMG wrote: |
actually I am asked to convert the ESQL code in Java to insert data in a Oracle DB using JDBC connection.
The code parses the input message taking some data from the DB and after some manipulation inserts the data into the DB. |
Your original question appears to have gotten lost in all of this discussion & I apologise for my part in this.
I'm the last person to advise on Java but will ask why this is being done. Having done the whole thing about Java v ESQL I don't see why you'd change to using a JDBC connection from an ODBC connection. Especially when you're not a Java person & hence the key reason for using Java inside WMB doesn't apply.
As to your problem, I can only endorse previous comments:
- push back on being asked to code in a language you don't know
- look at the samples _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
mqjeff |
Posted: Thu Feb 23, 2012 6:01 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Vitor wrote: |
- look at the samples |
other than the fact that writing Java and JDBC is entirely different than writing ESQL, the samples should be sufficient to get you through the basics.
but you're going to have quite a bit of fun getting the jdbc connection actually set up. |
|
Back to top |
|
 |
mqsiuser |
Posted: Thu Feb 23, 2012 8:46 am Post subject: |
|
|
 Yatiri
Joined: 15 Apr 2008 Posts: 637 Location: Germany
|
@OP: If ESQL can use JDBC, then use it (JDBC). If not use ODBC. With passthru you can do anything on the db that you like (that i ever needed)... I fear that ODBC has limitations.
@gurus: Pls clearly state why ESQL is (is not) possible with JDBC.
Why should the data-access method (ok, its named like "Java" "JDBC") have to care about the (tranformation) node(s) ? _________________ Just use REFERENCEs |
|
Back to top |
|
 |
Vitor |
Posted: Thu Feb 23, 2012 8:56 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
mqsiuser wrote: |
@gurus: Pls clearly state why ESQL is (is not) possible with JDBC. |
ESQL uses the data source associated with the Compute node. As indicated here this is the ODBC datasource associated with and administered by WMB (mqsisetdbparms et al).
If you want a less "that's how the software works" answer, ESQL has no Java component & no JVM so can't associate with a JDBC. Remember WMB base is not written in Java, though bits of it are. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
mqsiuser |
Posted: Thu Feb 23, 2012 9:40 am Post subject: |
|
|
 Yatiri
Joined: 15 Apr 2008 Posts: 637 Location: Germany
|
O.k. then it's clear what to do: You have ESQL, so use ODBC (If you'd have a JCN you'd use JDBC).
@OP: Does your DB support both ?! Which DB do you have ? _________________ Just use REFERENCEs |
|
Back to top |
|
 |
OMG |
Posted: Thu Feb 23, 2012 10:14 pm Post subject: |
|
|
 Novice
Joined: 20 Feb 2012 Posts: 18
|
The main problem is that I am not a Java person but I have to code it in Java using JDBC only. That's the given criteria and the biggest constraint also.
I have checked some sample where XPATH were used to traverse the input xml tree. I tried to use it but it's not taking the values from input message in the variables where as in ESQL it's very easy to pick the values from the incoming message tree directly. In this case every time the variables are taking value as null.
Is there anyone to solve this problem??
It will be great if you can explain it with an example (esql and corresponding java). Please show me any way out. It's urgent! |
|
Back to top |
|
 |
smdavies99 |
Posted: Thu Feb 23, 2012 10:31 pm Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
OMG wrote: |
The main problem is that I am not a Java person but I have to code it in Java using JDBC only. That's the given criteria and the biggest constraint also.
....
It's urgent! |
It might be time for you to URGENTLY look for another job.
As has been said before, we are not here to do your job for you. Broker is not a J2EE App Server. If your management think that then they do need to be made to understand that fact.
As you don't know Java then you really are on a hiding to nothing. _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
mqsiuser |
Posted: Thu Feb 23, 2012 11:55 pm Post subject: |
|
|
 Yatiri
Joined: 15 Apr 2008 Posts: 637 Location: Germany
|
[quote="smdavies99"]
OMG wrote: |
The main problem is that I am not a Java person but I have to code it in Java using JDBC only. That's the given criteria and the biggest constraint also. |
I could understand if this is about LIST or Erlang or Cobol, but Java and C (ESQL) - almost no difference !
It is honorable that you have a solid job in IT and want to write interfaces for a living ! - keep going.
For you problem: Try to get firstchild and nextsibling with the Java-API for MBElement (and skipp the idea with xPath). _________________ Just use REFERENCEs |
|
Back to top |
|
 |
adubya |
Posted: Fri Feb 24, 2012 12:00 am Post subject: |
|
|
Partisan
Joined: 25 Aug 2011 Posts: 377 Location: GU12, UK
|
OMG wrote: |
The main problem is that I am not a Java person |
Does the person who gave you the task understand this ? If it's so urgent then why give the task to someone who has no experience in Java. And what kind of code would you manage to cobble together anyway, more bug risk, maintenance overhead etc etc. |
|
Back to top |
|
 |
mqsiuser |
Posted: Fri Feb 24, 2012 12:56 am Post subject: |
|
|
 Yatiri
Joined: 15 Apr 2008 Posts: 637 Location: Germany
|
adubya wrote: |
OMG wrote: |
The main problem is that I am not a Java person |
Does the person who gave you the task understand this ? If it's so urgent then why give the task to someone who has no experience in Java. And what kind of code would you manage to cobble together anyway, more bug risk, maintenance overhead etc etc. |
You need to start one day. Probably this will not become the best interface ever, but inserting data in a DB (with Java), why not start with that (if your msg structure isn't that complex, etc.) ?! _________________ Just use REFERENCEs |
|
Back to top |
|
 |
joebuckeye |
Posted: Fri Feb 24, 2012 5:41 am Post subject: |
|
|
 Partisan
Joined: 24 Aug 2007 Posts: 365 Location: Columbus, OH
|
mqsiuser wrote: |
You need to start one day. Probably this will not become the best interface ever, but inserting data in a DB (with Java), why not start with that (if your msg structure isn't that complex, etc.) ?! |
True, but then the employer should be providing a mentor on how to do this, not forcing someone to the internet to look for clues. |
|
Back to top |
|
 |
lancelotlinc |
Posted: Fri Feb 24, 2012 5:46 am Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
joebuckeye wrote: |
mqsiuser wrote: |
You need to start one day. Probably this will not become the best interface ever, but inserting data in a DB (with Java), why not start with that (if your msg structure isn't that complex, etc.) ?! |
True, but then the employer should be providing a mentor on how to do this, not forcing someone to the internet to look for clues. |
GAG.
http://www.mqseries.net/phpBB2/viewtopic.php?t=60398
There was a time in recent history that freshers were responsible to train themselves in a career of their choosing. Some people borrow money on student loans to gain a career. Other people join the military to get essential training.
Why do you say it is not the fresher's responsibility to train themselves? _________________ http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER |
|
Back to top |
|
 |
Vitor |
Posted: Fri Feb 24, 2012 5:48 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
lancelotlinc wrote: |
There was a time in recent history that freshers were responsible to train themselves in a career of their choosing.
...
Why do you say it is not the fresher's responsibility to train themselves? |
Because times have changed. Mourn their passing as we mourn the passing of rock & roll and silent movies. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
Vitor |
Posted: Fri Feb 24, 2012 5:53 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
OMG wrote: |
The main problem is that I am not a Java person but I have to code it in Java using JDBC only. That's the given criteria and the biggest constraint also. |
It's a ridiculous constraint and I would be interested in knowing if this has any technical basis or is simply driven by someone in a management or architecture position thinking that WMB is an app server.
OMG wrote: |
Please show me any way out |
A quality resume writing service would seem to be your best bet. If your management are prepared to drop an impossible requirement on you in the knowledge that even if the software acted the way they thought it did you don't have the skills to code it, then that's a management with no consideration for their staff. This will be reflected in pay raises, working hours and career longevity when things go bad. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
|