Win a copy of Classic Computer Science Problems in Swift this week in the iOS forum!

gauri phadtare

+ Follow
since Oct 04, 2012
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by gauri phadtare

Hi Friends,

I have declared a UDT(User Defined Types) say CustomType in SQL server 2008.I m using this Data type as an IN parameter for a Stored
procedure.I want to call this procedure from a java class.
To do this i have done the following:
created a class called CustomType which implements SQLData

public class CustomType implements SQLData {

String name ;
int year ;
String sql_type = "CustomType_t";

public String getSQLTypeName() throws SQLException {
return sql_type;

public void readSQL(SQLInput arg0, String type) throws SQLException {
sql_type = type;
name = arg0.readString() ;
year = arg0.readInt() ;


public void writeSQL(SQLOutput arg0) throws SQLException {
arg0.writeString(name) ;
arg0.writeInt(year) ;



My main java class looks like this:

public class Proc2Test {

public static void main(String[] args) {
msmsqlTest() ;

public static void msmsqlTest()

Connection con = null ;
CallableStatement cStatement = null ;
ResultSet rs = null ;
String url = "jdbc:sqlserver://localhost:1433;databaseName=testDB;username=abc;password=xyz";
String driver = "";
con = DriverManager.getConnection(url);
java.util.Map map = con.getTypeMap();


cStatement = con.prepareCall("{call abc2(?,?)}") ;

CustomType x = new CustomType() ; = "ABC" ;
x.year = 20 ;

cStatement.setObject("para1", x, java.sql.Types.OTHER);
cStatement.registerOutParameter(2,Types.INTEGER) ;
rs = cStatement.executeQuery();
catch(Exception ex)
ex.printStackTrace() ;


when i run this code i get the following exception: This operation is not supported.
at Source)
at Source)
at Source)
at com.mindcraft.test.Proc2Test.msmsqlTest(
at com.mindcraft.test.Proc2Test.main(

This exception occurs at con.setTypeMap(map)

My problem is how do i call a store proc of SQL server, whose input parameter is a custom Database type?
How do i map the a pojo with custom database type of SQL server 2008 and send that to the stored proc ?
Does sql server 2008 jdbc driver implement Connection.setTypeMap() method?

5 years ago