稿件发布字数限制

摘要:
报错:java.sql.SQLException: ORA-01461: 仅能绑定要插入 LONG 列的 LONG 值
其实质是clob值得插入问题.

网上的解决办法:

文献1:https://www.cnblogs.com/xiaotiannet/p/3846966.html
他里面提到的方法我感觉是c#或者.net的方法,我在java里面没有找到相应的包。需要用using Oracle.DataAccess.Types;
using Oracle.DataAccess.Client;类似这种
https://blog.csdn.net/studyzy/article/details/11524527
无奈放弃。

文献2:https://blog.csdn.net/WangJQ12/article/details/78772311
使用mybatis的框架,但是工会的框架不是mybatis,不能用。放弃

文献3:https://blog.csdn.net/qiruiduni/article/details/37882031
这种方法应该是比较通用的,但是我意外的发现其实什么都不用加,就可以插入了。所以也没有用到。

最终的解决办法:

最开始是想用文献2的方法,但是gh的框架,不允许,只能自己实现一个controller了,本来想用拦截器,但是框架里面找不到bean的配置地方,用filter也行,但是我觉得有点麻烦,偶然发现了rdcp.request然后就用了controller

补充:

关于发布的问题,
1.本来我添加了一个java文件,我觉得应该改一下class,但是我查看了out目录,并没有发现class文件,就算我手动编译我也不知道放在哪里,后来我意外的发现,直接把java文件放上去,然后成了,也就是说不需要编译 连重启都不需要

2.另外就是数据库连接格式的问题,官网用的是oracle 12 本地用的是 oracle 11 ,发现后台报错,查看了下怀疑是 url的格式好像有点区别,其他都不变,需要改下url
private static String URL = “jdbc:oracle:thin:@xxx:1521:orcl”;(本地和远程都可以)

核心代码如下:

jsp

    var CUR_USER_ID= $("#CUR_USER_ID").val();
            rdcp.request("!gh/manu/~java/Dbjz_manu.dbjzApply",{"manu_id":manu_id,"company":company,"CUR_USER_ID":CUR_USER_ID,"content":content,"author_one":author_one,"author_two":author_two,"author_three":author_three,"content_text":text},function(data){
                if(data.header.code == 0)
                {
                    $.messager.alert("提示","插入成功!","info",function () {
                        cancel();

                    });
                }
            });

        }

java

  public JSONObject dbjzApply() {
        connection = getConnection();

        String sqlStr = " insert into bi_manu(id,company,job_num,content,state,create_user,create_time,author_one,author_two,author_three,dept_id," +
                "content_text,author_one_account,author_two_account,author_three_account)" +
                "values( ?,?,?,?,-1,?," +
                "sysdate,?,?,?,?,?,?,?,?)";


        Map<String, Object> map = new HashMap<String, Object>();

        RequestWrapper request = ApplicationManager.getRequest();
        String manu_id = request.getParameter("manu_id");
        String company = request.getParameter("company");
        String CUR_USER_ID = request.getParameter("CUR_USER_ID");
        String job_num = request.getParameter("CUR_USER_ID");
        String content = request.getParameter("content");
        String author_one = request.getParameter("author_one");
        String author_two = request.getParameter("author_two");
        String author_three = request.getParameter("author_three");
        String content_text = request.getParameter("content_text");
        String author_one_account = request.getParameter("author_one_account");
        String author_two_account = request.getParameter("author_two_account");
        String author_three_account = request.getParameter("author_three_account");
        String create_user = request.getParameter("CUR_USER_ID");
        String dept_id = "";

    /*  String  manu_id="11";
        String company="11";
        String job_num="11";
        String content="11";
        String create_user="11";
        String author_one="11";
        String author_two="11";
        String author_three="11";
        String dept_id="2";
        String content_text="11";
        String author_one_account="11";
        String author_two_account="11";
        String author_three_account="11";
        String CUR_USER_ID="1";*/

     /*   System.out.println("id:" + manu_id);
        System.out.println("content:" + content);
        System.out.println("company:" + company);
        System.out.println("content:" + content);
        System.out.println("author_one:" + author_one);
        System.out.println("author_two:" + author_two);

        System.out.println("content_text:" + content_text);
        System.out.println("author_one_account:" + author_one_account);
        System.out.println("author_two_account:" + author_two_account);
        System.out.println("author_three_account:" + author_three_account);
*/


        JSONObject json;
        try {
            Connection conn = getConnection();
            Statement sta = null;

            sta = conn.createStatement();
            String sql = "select DEPT_ID from sys_p_user where id=" + CUR_USER_ID;
            sta = conn.createStatement();
            rs = sta.executeQuery(sql);

            if (rs.next()) {
                dept_id = rs.getString(1);
            }


//            String sqlStr = " insert into BI_MANU(id,company) values(?,?)";
            pstm = conn.prepareStatement(sqlStr);
            pstm.setInt(1, Integer.parseInt(manu_id));
            pstm.setString(2, company);
            pstm.setString(3, job_num);
            pstm.setString(4, content);
//            pstm.setString(5, state);
            pstm.setString(5, create_user);
//            pstm.setString(7, create_time);
            pstm.setString(6, author_one);
            pstm.setString(7, author_two);
            pstm.setString(8, author_three);
            pstm.setString(9, dept_id);
            pstm.setString(10, content_text);
            pstm.setString(11, author_one_account);
            pstm.setString(12, author_two_account);
            pstm.setString(13, author_three_account);
            pstm.executeUpdate();
            System.out.println("写入成功");
            map.put("header", new Header(0, "success"));
            map.put("body", new HashMap());
            json = (JSONObject) JSON.toJSON(map);
            System.out.println("写入成功");

        } catch (Exception e) {
            e.printStackTrace();
            map.put("header", new Header(-1, "fail"));
            map.put("errorMsg", e.getMessage());
            json = (JSONObject) JSON.toJSON(map);
            return json;

        } finally {
            ReleaseResource();


        }
        return json;

    }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值