我在使用 JTDS 从 SQL Server 2005 数据库中的视图读取时遇到问题,并且在寻找解决方案时遇到了严重问题。
查询只是选择视图中的所有内容:
SELECT * FROM encounters_view WHERE patient_id = ?
此行抛出异常:
rset = selectAllEncountersByPatientId.executeQuery();
堆栈跟踪如下:
java.sql.SQLException: Error converting data type nvarchar to numeric.
at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:372)
at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2820)
at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2258)
at net.sourceforge.jtds.jdbc.TdsCore.isDataInResultSet(TdsCore.java:796)
at net.sourceforge.jtds.jdbc.JtdsResultSet.<init>(JtdsResultSet.java:134)
at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQLQuery(JtdsStatement.java:483)
at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeQuery(JtdsPreparedStatement.java:776)
at package_name.ClassName.method(Db_query_class.java:91)
at package_name.ClassName.main(Main_class.java:36)
查看数据类型:
id (unique(numeric(16,0)),not null)
provId (uniqueid(numeric(16,0)),not null)
patId (uniqueid(numeric(16,0)),not null)
mrn (varchar(20),not null)
visitId (uniqueid(numeric(16,0)),not null)
dttm (datetime, null)
apptType (name(varchar(255)),null)
apptStatus (name(varchar(255)),null)
refProvId (uniqueid(numeric(16,0)),not null)
pay (name(varchar(255)),not null)
zip (char(10),not null)
任何帮助将不胜感激。