简体   繁体   中英

How pass structure datatype to MS SQL database from Java

I am trying to call a stored procedure whose one parameter is sqlstructure type of MS SQL.I have passed String[] array but it threw this exception

WARNING: #{reportingCharts.getGraphValuesOnLocationBasis}: org.springframework.jdbc.UncategorizedSQLException: PreparedStatementCallback; uncategorized SQLException for SQL [{CALL dbo.up_Chart_SelectPersonCountByRankLocation(?,?,?,?,?)}]; SQL state [null]; error code [0]; The conversion from UNKNOWN to UNKNOWN is unsupported.; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: The conversion from UNKNOWN to UNKNOWN is unsupported.
javax.faces.FacesException: #{reportingCharts.getGraphValuesOnLocationBasis}: org.springframework.jdbc.UncategorizedSQLException: PreparedStatementCallback; uncategorized SQLException for SQL [{CALL dbo.up_Chart_SelectPersonCountByRankLocation(?,?,?,?,?)}]; SQL state [null]; error code [0]; The conversion from UNKNOWN to UNKNOWN is unsupported.; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: The conversion from UNKNOWN to UNKNOWN is unsupported.

So I think it is not accepting the array as a parameter for structure.
Unfortunately nowhere I can find an example about how to use it in java.
How can i pass my this array/list to this stored procedure? OR what would be the alternate for c# SqlDbType.Structured in java?

Refer to Microsoft JDBC Driver Team Blog , the JDBC driver supported by TVP has not been released yet. There is a workaround :packing the values in a binary form ,cracking it on the server and passing it to a table valued function. For JDBC driver this argument has to be passed as binary.
See this link you will find all the MSsql datatypes for java.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM