This may not be the best place to ask this but since I am running this inside Hibernate I thought I would try. I am getting the connection from the hibernate session.
I am attempting to run a callable statement and I am getting this error:
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Error converting data type nvarchar to uniqueidentifier.
this is the signature of the stored procedure.
CREATE PROCEDURE p_order_create
@output_message AS varchar(255) OUTPUT,
@executer_entity_id AS uniqueidentifier,
@executer_entity_hierarchy_id AS uniqueidentifier,
@executer_company_id AS uniqueidentifier,
@order_id AS uniqueidentifier OUTPUT,
@u_id_order_type AS uniqueidentifier,
@u_id_order_origination AS uniqueidentifier,
@entity_id_customer AS uniqueidentifier,
@entity_id_vendor AS uniqueidentifier,
@request_subject AS varchar(100) = NULL,
@request_description AS varchar(2000) = NULL,
@address_1 AS varchar(100) = '',
@address_2 AS varchar(100) = NULL,
@city AS varchar(50) = NULL,
@state AS char(2) = NULL,
@zip AS char(6) = '',
@zip4 AS char(4) = NULL,
@valid AS smallint = 0,
@latitude AS decimal(8,4) = NULL,
@longitude AS decimal(8,4) = NULL,
@reference_number AS varchar(50) = NULL,
@parcel_number AS varchar(50) = NULL,
@entity_id_source AS uniqueidentifier = NULL,
@reference_number_source AS varchar(50) = NULL,
@datetime_received AS datetime = NULL,
@u_id_order_priority as uniqueidentifier =null,
@order_number as varchar(12) =null
I am using the M$$QL Driver from M$ft. Here is the code that I am using to run the procedure in Java.
Code:
try{ String sql = "{ call p_order_create (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) }"; proc = con.prepareCall(sql); proc.registerOutParameter(1,Types.VARCHAR); //varchar proc.setString(2,order.getExecuterEntityId().toString()); //uniqueidentifier proc.setString(3,order.getExecuterEntityHierarchyId().toString()); //uniqueidentifier proc.setString(4,order.getExecuterCompanyId().toString()); //uniqueidentifier proc.registerOutParameter(5,Types.CHAR); //uniqueidentifier proc.setString(6,order.getIdOrderType().toString()); //uniqueidentifier proc.setString(7,order.getIdOrderOrigination().toString()); //uniqueidentifier proc.setString(8,order.getEntityIdCustomer().toString()); //uniqueidentifier proc.setString(9,order.getEntityIdVendor().toString()); //uniqueidentifier proc.setString(10,order.getRequestSubject()); //varchar proc.setString(11,order.getRequestDescription()); //varchar proc.setString(12,order.getAddress1()); //varchar proc.setString(13,order.getAddress2()); //varchar proc.setString(14,order.getCity()); //char proc.setString(15,order.getState()); //char proc.setString(16,order.getZip()); //char proc.setString(17,order.getZip4()); //char proc.setShort(18,order.getValid().shortValue()); //smallint proc.setInt(19,order.getLatitude().intValue()); //decimal proc.setInt(20,order.getLongitude().intValue()); //decimal proc.setString(21,order.getReferenceNumber()); //varchar proc.setString(22,order.getParcelNumber()); //varchar proc.setString(23,order.getEntityIdSource().toString()); //uniqueidentifier proc.setString(24,order.getReferenceNumberSource()); //varchar proc.setTimestamp(25,order.getDateTimeReceived()); //datetime proc.setString(26,order.getIdOrderPriority().toString()); //uniqueidentifier proc.setString(27,order.getOrderNumber()); //varchar LOG.error("SQL IS "+proc); proc.execute(); try{ BeanUtils.copyProperties(newOrder,order); }catch(java.lang.IllegalAccessException ex){ LOG.error(ex); }catch(java.lang.reflect.InvocationTargetException ex){ LOG.error(ex); } newOrder.setMessage( proc.getString(1) ); newOrder.setOrderId( proc.getString(5) ); }