久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

試圖將圖像插入數(shù)據(jù)庫(kù)得到 ORA-01460:未實(shí)現(xiàn)或不合

trying to insert image into database getting ORA-01460: unimplemented or unreasonable conversion requested error(試圖將圖像插入數(shù)據(jù)庫(kù)得到 ORA-01460:未實(shí)現(xiàn)或不合理的轉(zhuǎn)換請(qǐng)求錯(cuò)誤) - IT屋-程序員軟件開(kāi)發(fā)技術(shù)分享
本文介紹了試圖將圖像插入數(shù)據(jù)庫(kù)得到 ORA-01460:未實(shí)現(xiàn)或不合理的轉(zhuǎn)換請(qǐng)求錯(cuò)誤的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

我正在嘗試將圖像插入數(shù)據(jù)庫(kù)并使用自動(dòng)增量 photo_id.

我的表格列是:

PHOTO_ID(主鍵),用戶名 (fkey),圖片,PICTURE_TITLE,喜歡

我的代碼是

公共類 UploadPhotoDao {公共 int insertPhoto(UploadPhotoBean uploadBean){連接 con = null;PreparedStatement ps = null;整數(shù)索引 = 0;最終字符串查詢=插入照片詳細(xì)信息(PHOTO_ID,用戶名,圖片,圖片標(biāo)題,喜歡)值(PHOTO_ID_SEQUENCE.nextval,?,?,?,?)";嘗試 {con = ConnectionUtil.getConnection();ps = con.prepareStatement(查詢);ps.setString(1, uploadBean.getUsername());文件文件 =new File(uploadBean.getPicture());FileInputStream fis = new FileInputStream(file);ps.setBinaryStream(2, fis, fis.available());ps.setString(3, uploadBean.getPictureTitle());ps.setInt(4, 新整數(shù)(0));index = ps.executeUpdate();}捕捉(SQLException e){e.printStackTrace();} 捕捉(FileNotFoundException e){//TODO 自動(dòng)生成的 catch 塊e.printStackTrace();} 捕捉(IOException e){//TODO 自動(dòng)生成的 catch 塊e.printStackTrace();}最后 {ConnectionUtil.closeQuitly(ps);ConnectionUtil.closeQuitly(con);}回報(bào)指數(shù);}}

我收到了錯(cuò)誤:

<上一頁(yè)>java.sql.SQLException: ORA-01460: 請(qǐng)求未實(shí)現(xiàn)或不合理的轉(zhuǎn)換

解決方案

InputStream.available() 返回的大小流(Javadocs 中有明確記錄).

您需要查詢文件的大小,而不是輸入流中的可用字節(jié)":

ps.setBinaryStream(2, fis, (int)file.length());

根據(jù)您的 JDBC 驅(qū)動(dòng)程序版本,您也可以使用

ps.setBinaryStream(2, fis, file.length());

setBinaryStream(int, InputStream, long) 是在 JDBC 4.0 中定義的,因此并非所有驅(qū)動(dòng)程序版本都實(shí)現(xiàn).setBinaryStream(int, InputStream, int) 是 JDBC 2.0(如果我沒(méi)記錯(cuò)的話),應(yīng)該在所有版本中都可用.

I'm trying to insert an image into database and with auto increment photo_id.

my table columns are:

PHOTO_ID  (primary key),
USERNAME  (fkey),
PICTURE,
PICTURE_TITLE,
LIKES 

my code is

public class UploadPhotoDao {
    public int insertPhoto(UploadPhotoBean uploadBean){
        Connection con = null;
        PreparedStatement ps = null;

        int index = 0;
        final String query = "INSERT INTO PHOTOS_DETAILS (PHOTO_ID,USERNAME,PICTURE,PICTURE_TITLE,LIKES) VALUES (PHOTO_ID_SEQUENCE.nextval,?,?,?,?)";
            try {
                con = ConnectionUtil.getConnection();
                ps = con.prepareStatement(query);


                ps.setString(1, uploadBean.getUsername());
                File file =new File(uploadBean.getPicture());
                FileInputStream fis = new FileInputStream(file);
                ps.setBinaryStream(2, fis, fis.available());
                ps.setString(3, uploadBean.getPictureTitle());
                ps.setInt(4, new Integer(0));
                index = ps.executeUpdate();

            }
            catch (SQLException e) {
                e.printStackTrace();
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } 
            finally {
                    ConnectionUtil.closeQuitly(ps);
                    ConnectionUtil.closeQuitly(con);
            }
            return index;
    }
}

I'm getting the error:

java.sql.SQLException: ORA-01460: unimplemented or unreasonable conversion requested

解決方案

InputStream.available() does not return the size of the stream (which is clearly documented in the Javadocs).

You will need to query the size of the file, not the "available bytes" in the inputstream:

ps.setBinaryStream(2, fis, (int)file.length());

depending on the version of your JDBC driver you can also use

ps.setBinaryStream(2, fis, file.length());

But setBinaryStream(int, InputStream, long) is defined in JDBC 4.0 and thus not implemented by all driver versions. setBinaryStream(int, InputStream, int) is JDBC 2.0 (if I'm not mistaken) and should be available in all versions.

這篇關(guān)于試圖將圖像插入數(shù)據(jù)庫(kù)得到 ORA-01460:未實(shí)現(xiàn)或不合理的轉(zhuǎn)換請(qǐng)求錯(cuò)誤的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

How to wrap text around components in a JTextPane?(如何在 JTextPane 中的組件周?chē)h(huán)繞文本?)
MyBatis, how to get the auto generated key of an insert? [MySql](MyBatis,如何獲取插入的自動(dòng)生成密鑰?[MySql])
Inserting to Oracle Nested Table in Java(在 Java 中插入 Oracle 嵌套表)
Java: How to insert CLOB into oracle database(Java:如何將 CLOB 插入 oracle 數(shù)據(jù)庫(kù))
Why does Spring-data-jdbc not save my Car object?(為什么 Spring-data-jdbc 不保存我的 Car 對(duì)象?)
Use threading to process file chunk by chunk(使用線程逐塊處理文件)
主站蜘蛛池模板: 91porn在线 | 黄色一级视频免费 | 亚洲欧美在线免费观看 | 一区二区在线不卡 | 国产九九九九 | 精品国产乱码久久久久久图片 | 91免费福利在线 | 国产精品激情 | 国产无套一区二区三区久久 | 国产精品视频一区二区三区 | 亚洲精品一区二三区不卡 | 免费一区二区三区在线视频 | 2019精品手机国产品在线 | 成年无码av片在线 | 久久久国产一区二区三区 | 在线中文字幕亚洲 | 免费在线观看av的网站 | 欧美激情精品久久久久久变态 | 久久久久国产精品午夜一区 | 日韩av免费在线观看 | 国产精品亚洲精品日韩已方 | 国产精品欧美一区二区 | 国产午夜精品福利 | 欧美日韩福利视频 | 久久成人av | 欧美色人| 亚洲精品一区二 | 国产精品毛片一区二区三区 | 国产日韩精品一区 | 国产一区三区视频 | 中文字幕视频在线免费 | 欧美一区二区三区电影 | 区一区二在线观看 | 男人久久天堂 | 久久青| 国产精品国产精品国产专区不蜜 | 成人亚洲精品久久久久软件 | 自拍偷拍第一页 | 日本三级在线视频 | 亚洲欧洲成人在线 | 日韩色在线 |