The content of this blog is all from the Intelligence podcast, which is explained here.
Business requirements are as follows: When entering data on a JSP page, go to the background and enter into the database.
JSP page:
Field design for database:
Attention:
When some of the field content on the JSP page is empty, because the database fields are allowed to be empty, there is no mistake in thinking of doing so, in fact, MySQL is a good developer, but not with Oracle.
When using MyBatis, write the MyBatis configuration file as follows:
<InsertID= "Insert"ParameterType= "Cn.itcast.jk.domain.Factory"><!--When the database is Oracle, if the inserted data is empty, you must specify the default parameters. So here's the setting to write: Jdbctype=varchar.
MySQL database development does not have to specify Jdbctype=varchar so write. -insert into Factory_c (Factory_id,full_name,factory_name,contacts,phone,mobile,fax, Cnote,inspector,order_no,create_by,create_dept,create_time) VALUES (#{id,jdbctype=varchar},#{fullname,jdbctype=varchar },#{factoryname,jdbctype=varchar },#{contacts,< Span style= "color: #ff0000;" >jdbctype=varchar },#{phone,jdbctype=varchar },#{mobile,jdbctype=varchar },#{fax,jdbctype=varchar },#{cnote,jdbctype=varchar },#{inspector,jdbctype=varchar },#{orderno,jdbctype=integer },#{createby,jdbctype=varchar },#{createdept,jdbctype=varchar },#{createtime,jdbctype=timestamp }) </Insert>
I was afraid to use Oracle to develop this problem, so write this blog.
003 letter-Inserting data into an Oracle database, special handling when the field is allowed to be empty