ORA-01483: DATE 或 NUMBER 绑定变量的长度无效

hibernate、 java 、Spring环境下访问数据库,使用org.hibernate.Session 的get方法获取实体时出现

ORA-01483: DATE 或 NUMBER 绑定变量的长度无效

经反复排查,发现是因为记录中的一个clob字段为空导致的

临时解决方法
修改java代码使其默认值为一个空格

2018-06-08 14:51:54   Visit  20

Unsupported Image Type

public static BufferedImage toBufferedImage(File imgFile, int maxWidth, int maxHeight){
            if(imgFile.exists()){
                try {
                    // ImageIO 支持的图片类型 : [BMP, bmp, jpg, JPG, wbmp, jpeg, png, PNG, JPEG, WBMP, GIF, gif]
                    String types = Arrays.toString(ImageIO.getReaderFormatNames());
                    String suffix = null;
                    // 获取图片后缀
                    if(imgFile.getName().indexOf(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\".\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\") > -1) {
                        suffix = imgFile.getName().substring(imgFile.getName().lastIndexOf(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\".\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\") + 1);
                    }// 类型和图片后缀全部小写,然后判断后缀是否合法
                    if(suffix == null || types.toLowerCase().indexOf(suffix.toLowerCase()) < 0){
                        logger.error(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"Sorry, the image suffix is illegal. the standard image suffix is {}.\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\" + types);
                        return null;
                    }
                    Image img = ImageIO.read(imgFile);
                    // 根据原图与要求的缩略图比例,找到最合适的缩略图比例
                    int width = img.getWidth(null);
                    int height = img.getHeight(null);
                    int[] wh=calcWH(width,height,maxWidth,maxHeight);
                    int w=wh[0];
                    int h=wh[1];
                    if(w==width && h==height){
                        logger.debug(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"宽度高度没有压缩,返回源文件!\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\");
                        return ImageIO.read(imgFile);
                    }
               
                    BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
                    Graphics g = bi.getGraphics();
                    g.drawImage(img, 0, 0, w, h, null);
                    g.dispose();
                    return bi;
                } catch (IOException e) {
                    logger.error(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"generate thumbnail image failed.\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\",e);
                    try {
                        Image img ;

                        //Find a suitable ImageReader
                        java.util.Iterator readers = ImageIO.getImageReadersByFormatName(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"JPEG\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\");
                        javax.imageio.ImageReader reader = null;
                        while(readers.hasNext()) {
                            reader = (javax.imageio.ImageReader)readers.next();
                            if(reader.canReadRaster()) {
                                break;
                            }
                        }
                        //Stream the image file (the original CMYK image)
                        javax.imageio.stream.ImageInputStream input =   ImageIO.createImageInputStream(imgFile); 
                        reader.setInput(input); 

                        //Read the image raster
                        java.awt.image.Raster raster = reader.readRaster(0, null); 
                        raster.getWidth();
                        //Create a new RGB image
                        int width = raster.getWidth();
                        int height = raster.getHeight();
                        int[] wh=calcWH(width,height,maxWidth,maxHeight);
                        int w=wh[0];
                        int h=wh[1];
                        BufferedImage bi;
                        bi = createJPEG4(raster);
                        
                        
                        //bi = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR); 
                        //Fill the new image with the old raster
                        //bi.getRaster().setRect(w/width, h/height,raster); 
                        
                        //g.drawImage(raster, 0, 0, w, h, null);
                        img = bi.getScaledInstance(w, h, Image.SCALE_SMOOTH);
                        
                        BufferedImage bi2 = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
                        Graphics g = bi2.getGraphics();
                        g.drawImage(img, 0, 0, w, h, null);
                        g.dispose();
                        return bi2;
                    } catch (Exception e1) {
                        e1.printStackTrace();
                        //com.twelvemonkeys.imageio.plugins.jpeg.JPEGImageReader r = new com.twelvemonkeys.imageio.plugins.jpeg.JPEGImageReader();
                    }
                }
            }else{
                logger.warn(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"the image is not exist.\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\");
            }
            return null;
        }
    
        private static BufferedImage createJPEG4(Raster raster) {
            int w = raster.getWidth();
            int h = raster.getHeight();
            byte[] rgb = new byte[w * h * 3];
    
            // 彩色空间转换
            float[] Y = raster.getSamples(0, 0, w, h, 0, (float[]) null);
            float[] Cb = raster.getSamples(0, 0, w, h, 1, (float[]) null);
            float[] Cr = raster.getSamples(0, 0, w, h, 2, (float[]) null);
            float[] K = raster.getSamples(0, 0, w, h, 3, (float[]) null);
    
            for (int i = 0, imax = Y.length, base = 0; i < imax; i++, base += 3) {
                float k = 220 - K[i], y = 255 - Y[i], cb = 255 - Cb[i], cr = 255 - Cr[i];
    
                double val = y + 1.402 * (cr - 128) - k;
                val = (val - 128) * .65f + 128;
                rgb[base] = val < 0.0 ? (byte) 0 : val > 255.0 ? (byte) 0xff
                        : (byte) (val + 0.5);
    
                val = y - 0.34414 * (cb - 128) - 0.71414 * (cr - 128) - k;
                val = (val - 128) * .65f + 128;
                rgb[base + 1] = val < 0.0 ? (byte) 0 : val > 255.0 ? (byte) 0xff
                        : (byte) (val + 0.5);
    
                val = y + 1.772 * (cb - 128) - k;
                val = (val - 128) * .65f + 128;
                rgb[base + 2] = val < 0.0 ? (byte) 0 : val > 255.0 ? (byte) 0xff
                        : (byte) (val + 0.5);
            }
    
            raster = Raster.createInterleavedRaster(new DataBufferByte(rgb,
                    rgb.length), w, h, w * 3, 3, new int[] { 0, 1, 2 }, null);
    
            ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
            ColorModel cm = new ComponentColorModel(cs, false, true,
                    Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
            return new BufferedImage(cm, (WritableRaster) raster, true, null);
        }

参考https://www.aliyun.com/jiaocheng/822407.html

2018-05-07 23:33:09   Visit  42

npm 降级

npm i npm@4 -g

npm 淘宝镜像

npm install -g cnpm --registry=https://registry.npm.taobao.org
2018-04-17 12:28:09   Visit  55

现有的服务器(centos7.5)使用yum install nodejs 命令默认安装的是nodejs6。

curl --silent --location https://rpm.nodesource.com/setup_8.x | bash -
yum install nodejs -y
2018-04-16 23:59:29   Visit  63

设置nodejs全局安装路径

npm config set prefix \\\"D:\\\\Program Files\\\\nodejs\\\\node_global\\\"
npm config set cache \\\"D:\\\\Program Files\\\\nodejs\\\\node_cache\\\"

查看nodejs全局安装路径

 npm config get prefix

把node_global路径添加到系统的环境变量中

2018-04-02 19:27:46   Visit  91

设置浏览器滚动条样式

 ::-webkit-scrollbar-track-piece {
    background-color: #fff;
    -webkit-border-radius: 0
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px
}

::-webkit-scrollbar-thumb {
    height: 50px;
    background-color: #b8b8b8;
    -webkit-border-radius: 6px;
    outline: 2px solid #fff;
    outline-offset: -2px;
    border: 2px solid #fff;
    filter: alpha(opacity=50);
    -moz-opacity: 0.5;
    -khtml-opacity: 0.5;
    opacity: 0.5
}

::-webkit-scrollbar-thumb:hover {
    height: 50px;
    background-color: #878987;
    -webkit-border-radius: 6px
}
2018-03-29 16:43:16   Visit  69

nginx指向本地目录

访问 www.domain.com/file/ 的时候就会访问到本地F盘下的upload目录下的文件,而不是upload/file下的文件

location /file{
            root F:/upload/; 
            rewrite \'^/file(.*)$\' $1 break; 
}
2018-03-29 13:15:58   Visit  81

授权文件夹权限给用户

chown -R postgres leechgtablespace/

查找进程

ps -aux |grep nginx
2018-03-29 12:47:05   Visit  80

Freemarker

Freemarker中输出long类型带千位分隔符,也就是逗号。
需要把long类型转换为字符串,就可以正常输出完整的数字。

${totalCount?c}
2018-03-14 10:14:58   Visit  714

配置catalina.sh

# chkconfig: 112 63 37
# description: tomcat server init script
# Source Function Library
. /etc/init.d/functions

JAVA_HOME=/usr/local/jdk1.6.0_23/
CATALINA_HOME=/usr/local/tomcat

复制catalina.sh到init.d目录

cp -p /usr/local/tomcat/bin/catalina.sh /etc/init.d/tomcat8

注册到服务

chmod 755 /etc/init.d/tomcat8
chkconfig --add tomcat8
chkconfig tomcat8 on

启动服务

service tomcat8 start
Starting tomcat8 (via systemctl):                          [  OK  ]