我正在使用带有 sql server 2008 的 JDBC。我在表中有一个类型为“decimal(18, 2)”的列。我想使用“CallableStatement”向该列插入一个空值。我怎么做?
我试过了callstmt.setNull(14, java.sql.Types.DECIMAL);
。但这不起作用。
HTTP 状态 404 - /NSBMHCGcom.microsoft.sqlserver.jdbc.SQLServerException:%20Error%20converting%20data%20type%20nvarchar%20to%20numeric./eHRMS_AR_M_display_SetupOTConditions
这是我得到的错误。
类型状态报告
消息 /NSBMHCGcom.microsoft.sqlserver.jdbc.SQLServerException:%20Error%20converting%20data%20type%20nvarchar%20to%20numeric./eHRMS_AR_M_display_SetupOTConditions
说明 请求的资源 (/NSBMHCGcom.microsoft.sqlserver.jdbc.SQLServerException:%20Error%20converting%20data%20type%20nvarchar%20to%20numeric./eHRMS_AR_M_display_SetupOTConditions) 不可用。
这是代码的一部分。
strSQL = "INSERT INTO " + m_schema_name + ".[AR_M_OTConditions] ([ConditionDescription],[StartHour],[EndHour]"
+ " ,[Day],[IsActive],"
+ "[EntDate],[EntUser],[ModDate],[ModUser],[Rate],[MinOT],[MaxOT],[EmpCategory],[EmpType],[Condition],[MinHour],[MaxHour],[Amount]) VALUES (?,?,?,?,?,getDate(),?,getDate(),?,?,?,?,?,?,?,?,?,?)";
callstmt = conn.prepareCall(strSQL);
callstmt.setString(1, m_con_methods.met_formdata(reqstr, "TXT_LEVELNAME"));
callstmt.setString(2, m_con_methods.met_formdata(reqstr, "TXT_FROM"));
callstmt.setString(3, m_con_methods.met_formdata(reqstr, "TXT_TO"));
callstmt.setString(4, m_con_methods.met_formdata(reqstr, "TXT_FINYEAR"));
callstmt.setBoolean(5, true);
callstmt.setString(6, m_username);
callstmt.setString(7, m_username);
callstmt.setString(8, m_con_methods.met_formdata(reqstr, "TXT_RATE"));
callstmt.setString(9, m_con_methods.met_formdata(reqstr, "TXT_MIN") );
callstmt.setString(10, m_con_methods.met_formdata(reqstr, "TXT_MAX"));
callstmt.setString(11, m_con_methods.met_formdata(reqstr, "TXT_CHARGABLE_STATUS"));
callstmt.setString(12, m_con_methods.met_formdata(reqstr, "TXT_TYPE"));
callstmt.setString(13, m_con_methods.met_formdata(reqstr, "TXT_CONDITIONS"));
callstmt.setNull(14, java.sql.Types.DECIMAL);
callstmt.setString(15, m_con_methods.met_formdata(reqstr, "TXT_MAX_HOUR"));
callstmt.setString(16, m_con_methods.met_formdata(reqstr, "TXT_CONDITIONS_AMOUNT"));
==================================================== ====================================================
com.microsoft.sqlserver.jdbc.SQLServerException: Error converting data type nvarchar to numeric.
log4j:ERROR Could not find value for key log4j.appender.warn
log4j:ERROR Could not instantiate appender named "warn".
log4j:ERROR setFile(null,true) call failed.
java.io.FileNotFoundException: C:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.18\logs\NSBM.log (The system cannot find the path specified)
at java.io.FileOutputStream.openAppend(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:192)
at java.io.FileOutputStream.<init>(FileOutputStream.java:116)
at org.apache.log4j.FileAppender.setFile(FileAppender.java:290)
at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:164)
at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:257)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:133)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:97)
at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:689)
at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:647)
at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:544)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:440)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:476)
at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:471)
at org.apache.log4j.LogManager.<clinit>(LogManager.java:125)
at org.apache.log4j.Logger.getLogger(Logger.java:105)
at pwc.ehrms.common.CommonConnections.LogSystemErrors(CommonConnections.java:633)
at pwc.ehrms.master.eHRMS_AR_M_save_SetupOTConditions.service(eHRMS_AR_M_save_SetupOTConditions.java:165)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
==================================================== ====================================================