473,796 Members | 2,904 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Java UDT

Hello I am a newbie in DB2.

I am trying out the Mapping Java definitions to SQL on UDT from the
article "DB2's object-relational highlights: Store and invoke
structured type objects" by Kathryn Zeidenstein.
The url is :
http://www-128.ibm.com/developerwork...y/techarticle/
zeidenstein/0109zeidenstein .html#xforms

In the article , it is said that the use of Java classes to define SQL
types is possible.
When i created the example on the sql side, the following exception is
thrown :
com.ibm.db2.jcc .c.SqlException : The name "TEST_T1" has the wrong
number of qualifiers.

Following is the source that I have created :

On the java side :

package myProject;

import java.sql.SQLDat a;
import java.sql.SQLExc eption;
import java.sql.SQLInp ut;
import java.sql.SQLOut put;

public class TestUdt implements SQLData {

public String strVal;
public int intVal;
public char charVal;

public static final String TYPE_NAME = "TEST_T";

/**
* constructor to match the type in DB2
* @param strVal
* @param intVal
* @param charVal
*/
public TestUdt(String strVal, int intVal, char charVal) {
this.strVal = strVal;
this.intVal = intVal;
this.charVal = charVal;
}

/**
* readSQL()
* being called by JDBC driver to populates this object
* with data read from the database.
**/
public void readSQL(SQLInpu t in, String type)
throws SQLException {
strVal = in.readString() ;
intVal = in.readInt();
charVal = in.readString() .charAt(0);
}

/**
* Returns the fully-qualified
* name of the SQL user-defined type that this object represents (in
DB2).
*/
public String getSQLTypeName( ) throws SQLException {
return TYPE_NAME;
}
/**
* writeSQL()
* being called by JDBC driver to write this object
* to the given SQL data.
**/
public void writeSQL(SQLOut put out)
throws SQLException {
out.writeString (strVal);
out.writeInt(in tVal);
out.writeString (String.valueOf (charVal));
}

/**
* test method in UDT
* @return strVal + intVal + charVal
*/
public String printAllAttr() {
return strVal + "," + Integer.toStrin g(intVal) + "," +
String.valueOf( charVal);
}

/**
* test method in UDT
* @param newStr
*/
public void changestring(St ring newStr) {
strVal = newStr;
}
}
On the sql side :

CREATE TYPE EVIE.TEST_T1
EXTERNAL NAME 'EVIE.TESTUDT:m yProject.TestUd t'
LANGUAGE JAVA
USING SQLDATA
AS( STRVAL VARCHAR(100),
INTVAL INTEGER,
CHARVAL CHAR(20))
CONSTRUCTOR METHOD EVIE.TEST_T1 (s VARCHAR(10), d INT, c CHAR(20))
RETURNS EVIE.TEST_T1
SELF AS RESULT
EXTERNAL NAME 'EVIE.TESTUDT:m yProject.TestUd t';
I have compiled and archived myProject.TestU dt to a jar , and
installed it using sqlj.install_ja r command namely TESTUDT.jar under
user EVIE in my DB2.

Can anybody advice me on this matter?

Jan 29 '07 #1
4 3034
eviewcs wrote:
Hello I am a newbie in DB2.

I am trying out the Mapping Java definitions to SQL on UDT from the
article "DB2's object-relational highlights: Store and invoke
structured type objects" by Kathryn Zeidenstein.
The url is :
http://www-128.ibm.com/developerwork...y/techarticle/
zeidenstein/0109zeidenstein .html#xforms

In the article , it is said that the use of Java classes to define SQL
types is possible.
When i created the example on the sql side, the following exception is
thrown :
com.ibm.db2.jcc .c.SqlException : The name "TEST_T1" has the wrong
number of qualifiers.

Following is the source that I have created :

On the java side :

package myProject;

import java.sql.SQLDat a;
import java.sql.SQLExc eption;
import java.sql.SQLInp ut;
import java.sql.SQLOut put;

public class TestUdt implements SQLData {

public String strVal;
public int intVal;
public char charVal;

public static final String TYPE_NAME = "TEST_T";

/**
* constructor to match the type in DB2
* @param strVal
* @param intVal
* @param charVal
*/
public TestUdt(String strVal, int intVal, char charVal) {
this.strVal = strVal;
this.intVal = intVal;
this.charVal = charVal;
}

/**
* readSQL()
* being called by JDBC driver to populates this object
* with data read from the database.
**/
public void readSQL(SQLInpu t in, String type)
throws SQLException {
strVal = in.readString() ;
intVal = in.readInt();
charVal = in.readString() .charAt(0);
}

/**
* Returns the fully-qualified
* name of the SQL user-defined type that this object represents (in
DB2).
*/
public String getSQLTypeName( ) throws SQLException {
return TYPE_NAME;
}
/**
* writeSQL()
* being called by JDBC driver to write this object
* to the given SQL data.
**/
public void writeSQL(SQLOut put out)
throws SQLException {
out.writeString (strVal);
out.writeInt(in tVal);
out.writeString (String.valueOf (charVal));
}

/**
* test method in UDT
* @return strVal + intVal + charVal
*/
public String printAllAttr() {
return strVal + "," + Integer.toStrin g(intVal) + "," +
String.valueOf( charVal);
}

/**
* test method in UDT
* @param newStr
*/
public void changestring(St ring newStr) {
strVal = newStr;
}
}
On the sql side :

CREATE TYPE EVIE.TEST_T1
EXTERNAL NAME 'EVIE.TESTUDT:m yProject.TestUd t'
LANGUAGE JAVA
USING SQLDATA
AS( STRVAL VARCHAR(100),
INTVAL INTEGER,
CHARVAL CHAR(20))
CONSTRUCTOR METHOD EVIE.TEST_T1 (s VARCHAR(10), d INT, c CHAR(20))
RETURNS EVIE.TEST_T1
SELF AS RESULT
EXTERNAL NAME 'EVIE.TESTUDT:m yProject.TestUd t';
I have compiled and archived myProject.TestU dt to a jar , and
installed it using sqlj.install_ja r command namely TESTUDT.jar under
user EVIE in my DB2.

Can anybody advice me on this matter?
I would remove the "EVIE." part in the external name clauses. In front of
the colon goes the name of the JAR. After the colon comes the classname
and finally the method name.

--
Knut Stolze
DB2 z/OS Utilities Development
IBM Germany
Jan 29 '07 #2


On Jan 30, 3:22 am, Knut Stolze <sto...@de.ibm. comwrote:
eviewcs wrote:
Hello I am a newbie in DB2.
I am trying out the Mapping Java definitions to SQL on UDT from the
article "DB2's object-relational highlights: Store and invoke
structured type objects" by Kathryn Zeidenstein.
The url is :
http://www-128.ibm.com/developerwork...y/techarticle/
zeidenstein/0109zeidenstein .html#xforms
In the article , it is said that the use of Java classes to define SQL
types is possible.
When i created the example on the sql side, the following exception is
thrown :
com.ibm.db2.jcc .c.SqlException : The name "TEST_T1" has the wrong
number of qualifiers.
Following is the source that I have created :
On the java side :
package myProject;
import java.sql.SQLDat a;
import java.sql.SQLExc eption;
import java.sql.SQLInp ut;
import java.sql.SQLOut put;
public class TestUdt implements SQLData {
public String strVal;
public int intVal;
public char charVal;
public static final String TYPE_NAME = "TEST_T";
/**
* constructor to match the type in DB2
* @param strVal
* @param intVal
* @param charVal
*/
public TestUdt(String strVal, int intVal, char charVal) {
this.strVal = strVal;
this.intVal = intVal;
this.charVal = charVal;
}
/**
* readSQL()
* being called by JDBC driver to populates this object
* with data read from the database.
**/
public void readSQL(SQLInpu t in, String type)
throws SQLException {
strVal = in.readString() ;
intVal = in.readInt();
charVal = in.readString() .charAt(0);
}
/**
* Returns the fully-qualified
* name of the SQL user-defined type that this object represents (in
DB2).
*/
public String getSQLTypeName( ) throws SQLException {
return TYPE_NAME;
}
/**
* writeSQL()
* being called by JDBC driver to write this object
* to the given SQL data.
**/
public void writeSQL(SQLOut put out)
throws SQLException {
out.writeString (strVal);
out.writeInt(in tVal);
out.writeString (String.valueOf (charVal));
}
/**
* test method in UDT
* @return strVal + intVal + charVal
*/
public String printAllAttr() {
return strVal + "," + Integer.toStrin g(intVal) + "," +
String.valueOf( charVal);
}
/**
* test method in UDT
* @param newStr
*/
public void changestring(St ring newStr) {
strVal = newStr;
}
}
On the sql side :
CREATE TYPE EVIE.TEST_T1
EXTERNAL NAME 'EVIE.TESTUDT:m yProject.TestUd t'
LANGUAGE JAVA
USING SQLDATA
AS( STRVAL VARCHAR(100),
INTVAL INTEGER,
CHARVAL CHAR(20))
CONSTRUCTOR METHOD EVIE.TEST_T1 (s VARCHAR(10), d INT, c CHAR(20))
RETURNS EVIE.TEST_T1
SELF AS RESULT
EXTERNAL NAME 'EVIE.TESTUDT:m yProject.TestUd t';
I have compiled and archived myProject.TestU dt to a jar , and
installed it using sqlj.install_ja r command namely TESTUDT.jar under
user EVIE in my DB2.
Can anybody advice me on this matter?I would remove the "EVIE." part in the external name clauses. In front of
the colon goes the name of the JAR. After the colon comes the classname
and finally the method name.

--
Knut Stolze
DB2 z/OS Utilities Development
IBM Germany

I removed the "EVIE." part on external name but same exception is
still being thrown :(
The exception is : com.ibm.db2.jcc .c.SqlException : The name "TEST_T1"
has the wrong number of qualifiers.
What is the meaning of "qualifiers " in the exception?

Jan 30 '07 #3
eviewcs wrote:
Hello I am a newbie in DB2.

I am trying out the Mapping Java definitions to SQL on UDT from the
article "DB2's object-relational highlights: Store and invoke
structured type objects" by Kathryn Zeidenstein.
The url is :
http://www-128.ibm.com/developerwork...y/techarticle/
zeidenstein/0109zeidenstein .html#xforms

In the article , it is said that the use of Java classes to define SQL
types is possible.
When i created the example on the sql side, the following exception is
thrown :
com.ibm.db2.jcc .c.SqlException : The name "TEST_T1" has the wrong
number of qualifiers.

Following is the source that I have created :

On the java side :

package myProject;

import java.sql.SQLDat a;
import java.sql.SQLExc eption;
[...]
}
On the sql side :

CREATE TYPE EVIE.TEST_T1
EXTERNAL NAME 'EVIE.TESTUDT:m yProject.TestUd t'
LANGUAGE JAVA
USING SQLDATA
AS( STRVAL VARCHAR(100),
INTVAL INTEGER,
CHARVAL CHAR(20))
CONSTRUCTOR METHOD EVIE.TEST_T1 (s VARCHAR(10), d INT, c CHAR(20))
RETURNS EVIE.TEST_T1
SELF AS RESULT
EXTERNAL NAME 'EVIE.TESTUDT:m yProject.TestUd t';
I have question on this statement of yours: DB2 does not support this syntax
(see here:
http://publib.boulder.ibm.com/infoce.../r0000933.htm).
Thus, I'm a but surprised that you didn't get a syntax error. Referring to
the article that you cited, I guess this may be stuff that has been
withdrawn in V8 (and did work in V7). So I would suggest that you don't
use this functionality.

As for the error message. My take on this would be that the first EXTERNAL
NAME clause receives the class name. All additional EXTERNAL NAME clauses
specify the method within that class only. So this may be correct:

CREATE TYPE EVIE.TEST_T1
EXTERNAL NAME 'EVIE.TESTUDT:m yProject.TestUd t'
LANGUAGE JAVA
USING SQLDATA
AS( STRVAL VARCHAR(100),
INTVAL INTEGER,
CHARVAL CHAR(20))
CONSTRUCTOR METHOD EVIE.TEST_T1 (s VARCHAR(10), d INT, c CHAR(20))
RETURNS EVIE.TEST_T1
SELF AS RESULT
EXTERNAL NAME 'TestUdt';
--
Knut Stolze
DB2 z/OS Utilities Development
IBM Germany
Jan 30 '07 #4
On Jan 31, 4:19 am, Knut Stolze <sto...@de.ibm. comwrote:
eviewcs wrote:
Hello I am a newbie in DB2.
I am trying out the Mapping Java definitions to SQL on UDT from the
article "DB2's object-relational highlights: Store and invoke
structured type objects" by Kathryn Zeidenstein.
The url is :
http://www-128.ibm.com/developerwork...y/techarticle/
zeidenstein/0109zeidenstein .html#xforms
In the article , it is said that the use of Java classes to define SQL
types is possible.
When i created the example on the sql side, the following exception is
thrown :
com.ibm.db2.jcc .c.SqlException : The name "TEST_T1" has the wrong
number of qualifiers.
Following is the source that I have created :
On the java side :
package myProject;
import java.sql.SQLDat a;
import java.sql.SQLExc eption;
[...]
}
On the sql side :
CREATE TYPE EVIE.TEST_T1
EXTERNAL NAME 'EVIE.TESTUDT:m yProject.TestUd t'
LANGUAGE JAVA
USING SQLDATA
AS( STRVAL VARCHAR(100),
INTVAL INTEGER,
CHARVAL CHAR(20))
CONSTRUCTOR METHOD EVIE.TEST_T1 (s VARCHAR(10), d INT, c CHAR(20))
RETURNS EVIE.TEST_T1
SELF AS RESULT
EXTERNAL NAME 'EVIE.TESTUDT:m yProject.TestUd t';

I have question on this statement of yours: DB2 does not support this syntax
(see here:http://publib.boulder.ibm.com/infoce...m.ibm.db2....).
Thus, I'm a but surprised that you didn't get a syntax error. Referring to
the article that you cited, I guess this may be stuff that has been
withdrawn in V8 (and did work in V7). So I would suggest that you don't
use this functionality.

As for the error message. My take on this would be that the first EXTERNAL
NAME clause receives the class name. All additional EXTERNAL NAME clauses
specify the method within that class only. So this may be correct:

CREATE TYPE EVIE.TEST_T1
EXTERNAL NAME 'EVIE.TESTUDT:m yProject.TestUd t'
LANGUAGE JAVA
USING SQLDATA
AS( STRVAL VARCHAR(100),
INTVAL INTEGER,
CHARVAL CHAR(20))
CONSTRUCTOR METHOD EVIE.TEST_T1 (s VARCHAR(10), d INT, c CHAR(20))
RETURNS EVIE.TEST_T1
SELF AS RESULT
EXTERNAL NAME 'TestUdt';

--
Knut Stolze
DB2 z/OS Utilities Development
IBM Germany
I've just found out that the integration with java on structured type
as introduced in the article was actually a feature not implemented in
DB2. Seems to me that the codes provided in the article was not tested
hence the various syntax errors.
It got me a little frustfrated because of the time I spent to try make
the codes work as I believed that IBM articles should provide reliable
information *frown*.

Thanks anyway.

Jan 31 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
6816
by: Ravi Tallury | last post by:
Hi We are having issues with our application, certain portions of it stop responding while the rest of the application is fine. I am attaching the Java Core dump. If someone can let me know what the issue is. Thanks Ravi
1
6920
by: ptaz | last post by:
Hi I'm trying to run a web page but I get the following error. Ca anyone please tell me a solution to this. Thanks Ptaz HTTP Status 500 - type Exception report
11
9274
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in C++. I find my self sometimes, trying Object app = Object(); Object *app = Object(); Object app = new Object();
0
5658
by: mailkhurana | last post by:
Hii , I am trying to use a type 2 driver to connect to DB2 0n AIX 5 I have a small java test to class to establish a conneciton with the db .. I am NOT using WAS or any appserver When I try to connect to the DB I get the following exception at java.lang.ClassLoader$NativeLibrary.load(Native Method) at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2120)
1
9657
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej and I was wondering if anyone here would be able to give me some tips for young players such as myself, for learning the language. Is this the best Newsgroup for support with JAVA?
12
5930
by: Mark Fink | last post by:
I wrote a Jython class that inherits from a Java class and (thats the plan) overrides one method. Everything should stay the same. If I run this nothing happens whereas if I run the Java class it says: usage: java fit.FitServer host port socketTicket -v verbose I think this is because I do not understand the jython mechanism for inheritance (yet).
0
3290
by: jaywak | last post by:
Just tried running some code on Linux (2.4.21-32.0.1.EL and Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)) and Windows XPSP2 (with Java HotSpot(TM) Client VM (build 1.5.0_11-b03, mixed mode, sharing)) and in both cases, get the following list returned from calling getDeclaredFields() on java.lang.ClassLoader via this code snippet: Field fields = loaderClass.getDeclaredFields(); for (int i = 0; i <...
1
4309
by: jaimemartin | last post by:
hello, I want to validate an xml by means of a schema (xsd). To do that first of all I´m using a SchemaFactory. The problem is that if I run the code in Windows all works fine, but If I run it in Linux there is an error. The code that fails is the following: SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); I´m sure that code is ok. In fact, I´ve found that in several...
0
3292
oll3i
by: oll3i | last post by:
package library.common; import java.sql.ResultSet; public interface LibraryInterface { public ResultSet getBookByAuthor(String author); public ResultSet getBookByName(String name);
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10467
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10244
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10021
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9061
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6802
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5454
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2931
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.