if(objParams!=null){
for(int i=0;i<objParams.length;i++)
{
ps.setObject(i+1, objParams[i]);
}
}
编译通过,但运行时提示ps.setObject(i+1, objParams[i]);出错,出错信息如下:
Exception in thread "main" java.lang.NoClassDefFoundError: microsoft/sql/DateTim
eOffset
at com.microsoft.sqlserver.jdbc.JavaType.<clinit>(DataTypes.java:470)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.setObjectNoTy
pe(SQLServerPreparedStatement.java:910)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.setObject(SQL
ServerPreparedStatement.java:921)
at DBHelper.getRS(DataBaseDemo.java:41)
at DataBaseDemo.sel(DataBaseDemo.java:192)
at DataBaseDemo.Options(DataBaseDemo.java:114)
at DataBaseDemo.selOption(DataBaseDemo.java:97)
at DataBaseDemo.main(DataBaseDemo.java:71)
Caused by: java.lang.ClassNotFoundException: microsoft.sql.DateTimeOffset
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 8 more
我尝试将ps.setObject改成直接写出一个SQL语句就不会报错,用prepareStatement的setObject方法就会报错,拜托各位了。