473,379 Members | 1,530 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

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.SQLData;
import java.sql.SQLException;
import java.sql.SQLInput;
import java.sql.SQLOutput;

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(SQLInput 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(SQLOutput out)
throws SQLException {
out.writeString(strVal);
out.writeInt(intVal);
out.writeString(String.valueOf(charVal));
}

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

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

CREATE TYPE EVIE.TEST_T1
EXTERNAL NAME 'EVIE.TESTUDT:myProject.TestUdt'
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:myProject.TestUdt';
I have compiled and archived myProject.TestUdt to a jar , and
installed it using sqlj.install_jar command namely TESTUDT.jar under
user EVIE in my DB2.

Can anybody advice me on this matter?

Jan 29 '07 #1
4 3000
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.SQLData;
import java.sql.SQLException;
import java.sql.SQLInput;
import java.sql.SQLOutput;

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(SQLInput 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(SQLOutput out)
throws SQLException {
out.writeString(strVal);
out.writeInt(intVal);
out.writeString(String.valueOf(charVal));
}

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

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

CREATE TYPE EVIE.TEST_T1
EXTERNAL NAME 'EVIE.TESTUDT:myProject.TestUdt'
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:myProject.TestUdt';
I have compiled and archived myProject.TestUdt to a jar , and
installed it using sqlj.install_jar 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.SQLData;
import java.sql.SQLException;
import java.sql.SQLInput;
import java.sql.SQLOutput;
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(SQLInput 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(SQLOutput out)
throws SQLException {
out.writeString(strVal);
out.writeInt(intVal);
out.writeString(String.valueOf(charVal));
}
/**
* test method in UDT
* @return strVal + intVal + charVal
*/
public String printAllAttr() {
return strVal + "," + Integer.toString(intVal) + "," +
String.valueOf(charVal);
}
/**
* test method in UDT
* @param newStr
*/
public void changestring(String newStr) {
strVal = newStr;
}
}
On the sql side :
CREATE TYPE EVIE.TEST_T1
EXTERNAL NAME 'EVIE.TESTUDT:myProject.TestUdt'
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:myProject.TestUdt';
I have compiled and archived myProject.TestUdt to a jar , and
installed it using sqlj.install_jar 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.SQLData;
import java.sql.SQLException;
[...]
}
On the sql side :

CREATE TYPE EVIE.TEST_T1
EXTERNAL NAME 'EVIE.TESTUDT:myProject.TestUdt'
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:myProject.TestUdt';
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:myProject.TestUdt'
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.SQLData;
import java.sql.SQLException;
[...]
}
On the sql side :
CREATE TYPE EVIE.TEST_T1
EXTERNAL NAME 'EVIE.TESTUDT:myProject.TestUdt'
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:myProject.TestUdt';

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:myProject.TestUdt'
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
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...
1
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
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...
0
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...
1
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...
12
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...
0
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
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...
0
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
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.