When I am trying to upload an Image using below code, I am getting following error : java.sql.SQLException: ORA-01460: unimplemented or unreasonable conversion requested
File image = new File("D:/"+fileName);
preparedStatement = connection.prepareStatement(query);
preparedStatement.setString(1,"Ayush");
fis = new FileInputStream(image);
preparedStatement.setBinaryStream(2, (InputStream)fis, (int)(image.length()));
int s = preparedStatement.executeUpdate();
if(s>0) {
System.out.println("Uploaded successfully !");
flag = true;
}
else {
System.out.println("unsucessfull to upload image.");
flag = false;
}
Please help me out.
DB Script :
CREATE TABLE ESTMT_SAVE_IMAGE
(
NAME VARCHAR2(50),
IMAGE BLOB
)
Its first cause is incompatible conversion but after seeing your DB script, I assume that you are not doing any conversion in your script.
There are other reported causes of the ORA-01460 as well:
Incompatible character sets can cause an ORA-01460
Using SQL Developer, attempting to pass a string to a bind variable value in excess of 4000 bytes can result in an ORA-01460
With ODP, users moving from the 10.2 client and 10.2 ODP to the 11.1 client and 11.1.0.6.10 ODP reported an ORA-01460 error. This was a bug that should be fixed by patching ODP to the most recent version.
Please see this
Related
We have a very simple Java code which executes an Oracle stored procedure using CallableStatement API. An Oracle stored procedure doesn't have an OUTPUT parameter defined, however in the Java Code we are trying to register an OUT parameter and retrieve it :
cs = cnDBCon.prepareCall("{call "+strStoredProcedureName+ "}");
cs.registerOutParameter(1, Types.NUMERIC);
cs.execute();
int isOk = cs.getInt(1);
According to Java API ( https://docs.oracle.com/javase/8/docs/api/java/sql/CallableStatement.html#getInt-int- ) when a return value is SQL NULL, the result is 0.
It worked perfectly fine when we were running on Java7/WebLogic 12.1.3. Since we switched to Java8/WebLogic 12.2.1 we started to get the error :
java.sql.SQLException: Missing defines
at oracle.jdbc.driver.Accessor.isNull(Accessor.java:744)
at oracle.jdbc.driver.NumberCommonAccessor.getInt(NumberCommonAccessor.java:73)
at oracle.jdbc.driver.OracleCallableStatement.getInt(OracleCallableStatement.java:1815)
at oracle.jdbc.driver.OracleCallableStatementWrapper.getInt(OracleCallableStatementWrapper.java:780)
at weblogic.jdbc.wrapper.CallableStatement_oracle_jdbc_driver_OracleCallableStatementWrapper.getInt(Unknown Source)
The obvious choice is to update the stored procedure or java code, but I am wondering about the reason the behavior changed. Is it a more strict JDBC driver?
I am trying to insert some binary data into a Firebird BLOB field using the API from a C++ application. My code is basically as follows (error handling omitted), after the official Firebird API manual:
extern db_conn_t global_db;
extern db_txn_t global_txn;
extern db_stmt_t global_stmt;
#define mydb (global_db.db_conn)
#define mytr (global_txn.dt_txn)
#define mystmt (global_stmt.ds_stmt)
#define status_vector (global_db.db_status)
isc_blob_handle hblob;
ISC_QUAD blobid;
XSQLDA *pinsqlda;
short flag[NUM_FIELDS];
memset (&flag[0], 0, NUM_FIELDS*sizeof(short));
hblob = NULL;
memset (&blobid, 0, sizeof(blobid));
isc_create_blob2(status_vector, &mydb, &mytr, &hblob, &blobid, 0, NULL);
isc_put_segment(status_vector, &hblob, payload_len, (char*)payload);
isc_close_blob(status_vector, &hblob);
pinsqlda = (XSQLDA *)calloc(1, XSQLDA_LENGTH(NUM_FIELDS));
...
pinsqlda->sqlvar[4].sqldata = (char *)&(blobid);
pinsqlda->sqlvar[4].sqltype = SQL_BLOB + 1;
pinsqlda->sqlvar[4].sqllen = sizeof(blobid);
pinsqlda->sqlvar[4].sqlind = &flag[4];
...
Then the query is submitted in the same way as many other instances elsewhere in the application, so I'm confident there is no problem there.
The blob creation completes with no error, but when the query is submitted, the returned error code is "invalid BLOB ID".
Can anyone see what I am doing wrong?
Update (from comment)
I just re-ordered my statements to put the blob creation after the definition of the XSQLDA structure and calls to isc_dsql_allocate_statement and isc_dsql_prepare, and lo! it works without error. So my immediate problem is solved, but I'd still appreciate knowing what exactly was going wrong.
You don't show statement prepare / execute nor the transaction start which is relevant for this problem: The error you post is usually caused by creating the blob in a different transaction than the one you use to execute the insert or update: as long as a blob id hasn't been linked to a table, it is not visible in other transactions.
I've used sqlcipher for 2 years. Yesterday I've upgraded to version 3.0.1 and tried to compile sqlcipher including arm64.
If I install new version of my app I can use new cipher lib without any problems.
But when I try to upgrade my previous version with DB made with sqlcipher 2.0 I get error 26.
It seems that new cipher can't decrypt my DB.
Also I tried to compile without arm64 support. The same problem.
I've solved my problem by using
PRAGMA cipher_migrate
which help to migrate from older DB structures to sqlcipher 3.0 (Details).
It must be executed right after setting the key.
If you want to read old DB (1.X/2.X) with new sqlcipher 3.0 use
PRAGMA kdf_iter = 4000
to set old value for kdf_iter. Now it equals 64,000 (Details)
In terms of lib sqlite db connection looks as follows:
int errorCode = SQLITE_ERROR;
sqlite3 *database = NULL;
errorCode = sqlite3_open_v2(path, &database, SQLITE_OPEN_READWRITE, NULL);
if (errorCode == SQLITE_OK) {
errorCode = sqlite3_key(database, key, (int)strlen(key));
}
if (errorCode == SQLITE_OK) {
errorCode = sqlite3_exec(database, "PRAGMA kdf_iter = 4000", NULL, NULL, NULL);
}
I try openning a .mdb file using CDaoDatabase, but at Open() catches an error: Unrecognised database format. I created the database first in MSAcces2007 and saved the file as .mdb, then i installed MSAcces2003 and created the file again, but there's the same error. Does anyone have a clue what's happening?
CString pathDB = "SMACDB\\Transports.mdb";
CDaoDatabase dbTransp;
try
{
dbTransp.Open(pathDB);
CDaoRecordset rs(&dbTransp);
COleVariant var1;
rs.Open(dbOpenSnapshot, "SELECT * FROM Transporturi");
while (!rs.IsEOF())
{
var1 = rs.GetFieldValue(1);
CString val = (LPCTSTR)var1.bstrVal;
g_carRestrict.pCarNmb.AddTail(val);
var1 = rs.GetFieldValue(2);
g_carRestrict.pAllowed.AddTail(var1.lVal);
rs.MoveNext();
}
rs.Close();
dbTransp.Close();
}
catch (CDaoException *pEx)
{
pEx->Delete();
}
Visual C++ 6 uses DAO 3.5 by default which does not support Access 2000 or later formats. To have MFC uses DAO 3.6, change the runtime version number to 6.01.
Suggested reading:
You receive an "Unrecognized database format" error message when you open a database created with Access 2000
I was trying to work with Oracle Database from Haskell and have faced with such problem.
So, there is this code.
module Main where
import Database.HDBC
import Database.HDBC.ODBC
main :: IO ()
main = do
let connectionString = "Driver={Microsoft ODBC for Oracle};Server=127.0.0.1;Uid=valera;Pwd=2562525;"
let ioconn = connectODBC connectionString
conn <- ioconn
vals <- quickQuery conn "SELECT * FROM PERSONS_TEST" []
print vals
return ()
Pretty simple, huh? But that won't work. With this connection string the error is
*** Exception: SqlError {seState = "[\"HY090\"]", seNativeError = -1, seErrorMsg = "sqlGetInfo SQL_TXN_CAPABLE: [\"0: [Microsoft][ODBC driver for Oracle]\\65533...
and then 65333 repeats many times. And with this
Provider=msdaora;Data Source=127.0.0.1;User Id=valera;Password=2562525;
the error is
*** Exception: SqlError {seState = "[\"IM002\"]", seNativeError = -1, seErrorMsg = "connectODBC/sqlDriverConnect: [\"0: [Microsoft][\\65533...
and 65333 repeats again till the end
I suppose, that the problem is in connection string, but I had tried a whole bunch of them (I've used http://www.connectionstrings.com/)
I'm using Haskell Platform 2011.4.0.0, GHC 7.0.4, Oracle Database XE 11.2 on Windows 7 64-bit. Microsoft MDAC SDK installed.
\65533 and so on is the symbols of ODBC driver error message string in your locale (RU?). I find the best way so on to develop in english locale system, thus error messages in ghci console shown in english language and can be read.