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?